Projectiles and mission area triggers
by J. Alan Atherton · in Torque Game Engine · 10/27/2004 (9:09 am) · 2 replies
I've figured out an alternate solution to this, as I didn't want to spend hours changing code unnecessarily. For my game I need to check if a projectile enters a mission trigger (not weapon or animation triggers). Basically you are shooting items into bins (or boxes, buckets, queues, whatever you want to call them). The problem is, if I use a collision box, the projectile explodes before it acutally enters the box. The other problem is a pile of stuff builds up as more items are put into the bin. I've solved the problems in my case by having two collision geometries (separate shape objects), one for the pile of stuff, and multiple collision boundaries for the box (to check the sides.
Another method I thought of is checking the collided object for a certain script variable (i.e. nonExplodingSurface or something) and if it is set, just pass through, but notify the onCollision calls anyway.
I spent just over an hour trying to get projectiles to collide with mission triggers, and couldn't ever get it to work. In projectile.cc I changed the static mask to include TriggerObjectType, and the castray still doesn't catch it. I tested this by setting a breakpoint just after the castray test in projectile.cc ( I forgot which function ), and it doesn't activate when the projectile is fired through a trigger... but it does when it hits the terrain (or anything else). My guess was the triggers need to be added in the bins (code bins this time), but I couldn't find where that would be done or how to do it.
Now, two questions about the above. Is enabling triggers for projectiles a smart thing to do, or am I going to break something? Is it a difficult, long, involved process to do so?
Short answers are fine... I probably will just stick with the collision box method, as I understand how to do that. But the time I spent looking for answers made me curious as to how this would be done. Many thanks.
Another method I thought of is checking the collided object for a certain script variable (i.e. nonExplodingSurface or something) and if it is set, just pass through, but notify the onCollision calls anyway.
I spent just over an hour trying to get projectiles to collide with mission triggers, and couldn't ever get it to work. In projectile.cc I changed the static mask to include TriggerObjectType, and the castray still doesn't catch it. I tested this by setting a breakpoint just after the castray test in projectile.cc ( I forgot which function ), and it doesn't activate when the projectile is fired through a trigger... but it does when it hits the terrain (or anything else). My guess was the triggers need to be added in the bins (code bins this time), but I couldn't find where that would be done or how to do it.
Now, two questions about the above. Is enabling triggers for projectiles a smart thing to do, or am I going to break something? Is it a difficult, long, involved process to do so?
Short answers are fine... I probably will just stick with the collision box method, as I understand how to do that. But the time I spent looking for answers made me curious as to how this would be done. Many thanks.
#2
Thanks for the comments, though.
10/28/2004 (5:01 am)
Acutally, I really am shooting (or lobbing) rocks into a big box. The problem is, the rocks can not only hit the bottom, but the sides of the box. If I just put one big collision box there, the rocks "explode" on nothing, rather than hitting the bottom or sides of the box. The animation part already works, and I've figured out how to do with with collision boxes, as described above. I'm really just curious about how trigger collision works, and how to allow projectiles to look for triggers. As far as I could see, the triggers themselves do no collision work... meaning they don't mask out objects. Anything that is a potential object (and is a SceneObject) should be picked up.Thanks for the comments, though.
Associate Anthony Rosenbaum