Picking objects using collision
by Ricardo Vladimiro · in Torque Game Builder · 01/04/2007 (8:25 am) · 4 replies
Hi and a great new year to everyone.
Having a problem here. I was using mouse event callbacks to detect when the mouse was over an object. But imagine that you have a circular graphic, in my case a soap bubble. It is possible to click the image's corners where there is no "object" only alpha channel that to a user is well... nothing.
So I decided to put a crosshair with a very small circular detection mode. Since my bubbles send and receive collisions, it was easy to mimick the mouse event with a collision callback.
The problem is, the crosshair sends physics making the bubbles bounce off the crosshair.
What I want to do is to have an object clicked, hovered, etc, like with the mouse event callbacks but only within the collision bounds of the bubbles. I tried to disable send and receiving physics from the crosshair, but still my bubbles bounce off. I can't disable physics from the bubbles since I want it to bounce one another.
Here's the collision and physics fields for the bubbles:
And for the crosshair:
Appart from this only the callback from the crosshair with a simple delete only for testing purposes.
Any ideas?
V
Having a problem here. I was using mouse event callbacks to detect when the mouse was over an object. But imagine that you have a circular graphic, in my case a soap bubble. It is possible to click the image's corners where there is no "object" only alpha channel that to a user is well... nothing.
So I decided to put a crosshair with a very small circular detection mode. Since my bubbles send and receive collisions, it was easy to mimick the mouse event with a collision callback.
The problem is, the crosshair sends physics making the bubbles bounce off the crosshair.
What I want to do is to have an object clicked, hovered, etc, like with the mouse event callbacks but only within the collision bounds of the bubbles. I tried to disable send and receiving physics from the crosshair, but still my bubbles bounce off. I can't disable physics from the bubbles since I want it to bounce one another.
Here's the collision and physics fields for the bubbles:
%this.setCollisionLayers ( %this.getLayer () ); %this.CollisionActiveReceive = "1"; %this.CollisionActiveSend = "1"; %this.CollisionResponse = "BOUNCE"; %this.CollisionDetectionMode = "CIRCLE"; %this.CollisionCircleScale = 0.70;
And for the crosshair:
Mass = "0"; CollisionActiveSend = "1"; CollisionPhysicsReceive = "0"; CollisionPhysicsSend = "0"; CollisionCallback = "1"; CollisionCircleScale = "0.1"; CollisionDetectionMode = "CIRCLE"; CollisionResponse = "CUSTOM";
Appart from this only the callback from the crosshair with a simple delete only for testing purposes.
Any ideas?
V
About the author
#2
01/06/2007 (5:55 am)
I can't do that since all my bubbles are produced via script, meaning I have no bubble on the level editor. I thought that someone had this problem before since it shouldn't be that uncommon. A player wants to click on an object, not it's alpha channel.
#3
01/08/2007 (8:26 am)
Ooooops... inside the documentation is written that the mouse picking uses the collision bounds, so problem solved.
#4
01/09/2007 (4:57 am)
Heh, yea I was wondering why this sounded so complicated. You can just add a collision poly to your objects that reflect the shape and the mouse events will be triggered based on that.
Bruce Slabinski