Continuous collision
by Thomas Buffon · in Torque Game Builder · 09/01/2007 (11:32 am) · 5 replies
Is there any way to check a continuous collision in TGB. To be more precise, what I'm looking for is to check if an object is being hit by an energy beam. As long as the object is within the beam it will continue to take damage, say 5 times a second. Is there any way of doing this using the existing collision system?
About the author
#2
09/05/2007 (12:23 am)
Thanks for the info James. It answered pretty much every question I had on this issue.
#3
If two objects are colliding, and a third object comes into the equation, it is ignored. TGB doesn't like multiple collisions =/ It does not even call onCollision. It makes life difficult some times.
09/05/2007 (5:00 am)
James,If two objects are colliding, and a third object comes into the equation, it is ignored. TGB doesn't like multiple collisions =/ It does not even call onCollision. It makes life difficult some times.
#4
09/05/2007 (8:39 am)
Ok, thats what I remembered from some time ago. In my experience rathar than starting by thinking "how can I use the collision system to do this", I think, "how can I avoid using the collision system to do this." '-)
#5
... and it works with multiple objects ^^
09/06/2007 (2:15 am)
You can use a trigger for the beam. With onenter and onleave callback you got what you need.... and it works with multiple objects ^^
Associate James Ford
Sickhead Games
However, I have had some problems with overlapping-colliding objects. At least in previous versions if two objects are overlapping and continually colliding it can cause collisions between other objects to not register. If you want to try to do this in oncollision I suggest some experimentation, like if two objects are both within the beam, make sure oncollision gets called for both of them.
I'm guessing you want the beam to damage everything within it, so it sounds to me like making the beam a trigger object and using the onstay callback could be easier then oncollision. Because what you are really interested in is what objects are inside the beam not when an object collides with it. However, onstay will get called every tick just like oncollision so if you only want damage to occur at a certain interval... Also the trigger object will need to be mounted to the visible object part of the beam so this is a bit more work to do.
Ahah, heres a very simple solution. Create a behavior in which you can define an interval (200ms) and onadd it creates a timer for that interval, then it just uses pickrect to look for any objects within its bounds and deals damage to all of them, no collision or callbacks required, and its easy to define the interval, and you don't need two objects mounted together.