CollisionPhysics with Triggers
by Dylan Taft · in General Discussion · 04/17/2012 (11:07 pm) · 0 replies
I spent a lot of time searching, a lot of people have an issue where triggers cause physics oddness. Like, if you have gravity enabled in Torque2D, and a player jumps through a trigger, the player can float or get stuck, they act like they have physics.
In other threads, people actually edited the C code to Torque's engine to work around it.
I found out it's OK to put triggers in their own collision group and layer, like 31, and then set your player object to not collide with that layer. Trigger will still work , without any physics, which is what you'd expect.
You can also mount a poly to the player object, and put it in it's own group, so the poly triggers the triggers as well instead of the player directly.
Hopefully someone finds that useful.
I'm planning on using triggers to adjust camera behavior for a sidescroller. Like, the camera normally will just follow the player. But say the player approaches a pit, I'm going to use triggers to change camera offset mount so the player can see down before they jump. If they turn back, the camera will go back to it's normal mount point. I think it's the best way to do it?
In other threads, people actually edited the C code to Torque's engine to work around it.
I found out it's OK to put triggers in their own collision group and layer, like 31, and then set your player object to not collide with that layer. Trigger will still work , without any physics, which is what you'd expect.
You can also mount a poly to the player object, and put it in it's own group, so the poly triggers the triggers as well instead of the player directly.
Hopefully someone finds that useful.
I'm planning on using triggers to adjust camera behavior for a sidescroller. Like, the camera normally will just follow the player. But say the player approaches a pit, I'm going to use triggers to change camera offset mount so the player can see down before they jump. If they turn back, the camera will go back to it's normal mount point. I think it's the best way to do it?
About the author