How to detect the type of an object
by Michael Hartlef · in Torque Game Builder · 01/24/2008 (6:42 am) · 4 replies
Hi folks,
inside the collision event, I would like to get the type of the destination object. I need this so I can react differently on collisions with TRIGGERS. Any information is welcome.
Michael
inside the collision event, I would like to get the type of the destination object. I need this so I can react differently on collisions with TRIGGERS. Any information is welcome.
Michael
#2
yes it makes sence. But I still hope that there is another way as I wanna but this into a behavior and make it more general.
01/24/2008 (8:43 pm)
Thanks Glenn,yes it makes sence. But I still hope that there is another way as I wanna but this into a behavior and make it more general.
#3
01/24/2008 (8:52 pm)
There are many ways to do this. What I usually do is use a switch$ command or string comparison test on the object.class...but that only works if you're using different classes for the different object types.
#4
Great, I will try that. Thanks guys for all the suggestions.
01/25/2008 (12:26 am)
So I can do a string compare to the object class (t2dtrigger) of the triggers. I didn't know that you could do that so easily. Great, I will try that. Thanks guys for all the suggestions.
Torque Owner Glenn Prince
1 - Player
2 - Enemies
3 - Tiles
4 - Items
5 - Triggers
6 - Special
Then you can do a case statement within the onCollision() call back to spawn off into the functions you want to handle the different type of collisions.
Does that make sense ?