Game Development Community

Collision call back without bouncing

by Andrew Deters · in Torque 2D Beginner · 01/15/2015 (11:50 pm) · 12 replies

I would like one of two objects to activate its onColission function when they occupy the same space, but I do not want ether of them bounce off the other. It should act like a ghost moving through a wall, but the wall still knows it happened.

#1
01/16/2015 (3:27 am)
What you are describing is known in Box2D/Torque 2D as a sensor. Setting an object's collision shape to be a sensor can trigger a callback but not a physics response.
#2
01/16/2015 (12:44 pm)
Thank you very much. I had looked through the documentation, but must have missed that when trying to find an answer. I was stuck in the old way of thinking, and was looking to find a collision response setting, or a way to turn receive collision off. Thanks again.
#3
01/16/2015 (11:57 pm)
Ok, I ran into a related issue. What if I wanted an object to bounce off the walls, but not interact with another object, but still have that other object trigger a callback?
#4
01/17/2015 (1:59 am)
Will the other object bounce off walls as well? It kind of hinges on that.
#5
01/17/2015 (2:04 am)
The other object should never move at all.
#6
01/17/2015 (7:22 am)
Make that *other* object a sensor. Your object can still bounce off wall fixtures, and just trigger a collision sensor for this *other* object.
#7
01/17/2015 (10:58 am)
That would work, and I had not thought of it before. But I did leave out some important info because I was falling asleep during my last comment. Normally the moving object (A BALL) would bounce off both the WALLS and the OTHER object, but when a special power is activated the BALL would move trough the OTHER object, and still bounce off the WALL. So I could just change the collision for the OTHER object to be a sensor the issue is there can be up to 100 (maybe more) of the other object in game at a time. I know how to run a for loop to change them all, but I am scared it would cause a lag spike switching that many objects at one moment. I am going to try it any way, but if there is another way please let me know.

Thanks to everyone for helping. I really appreciate it. This kind of thing was so much easier in the old Torque. I am moving an unfinished game from old Torque to MIT, and this was a working feature in the old Torque.
#8
01/17/2015 (5:56 pm)
If that is the case, just look at scene groups and collisions groups.

put the three types on their own scene group.

Have walls collide with the other groups.
have objects collide with everything as well

have ball normally collide with both, but if the power is active you can remove the other object from your collision group and it'll stop colliding with it.
#9
01/18/2015 (12:07 am)
That would have the right visual effect, but I still need the other object to know the ball passed through. Is there a non collision based way for objects to detect when they are in the same space.
#10
01/18/2015 (1:10 am)
If the other object doesn't move, just split it into two objects - One that is solid that is in one collision group, and one a sensor that is a different collision group.
#11
01/19/2015 (6:26 am)
How many ball objects are there? If there is only one then you don't have to iterate through all OTHER objects - you can do a container search for those only within a specified radius and only change those.

But I like Chase's idea.
#12
01/22/2015 (10:49 pm)
There can be up to 4 balls, but most of the time just one. Before making this post I did try to do that 2 object Idea with the ball, but it really messed up its physics having another object attached to it when it bounced. Maybe I did it wrong. I think I will try out that 2 object thing with the non-moving objects.