Is there a way to compare a TorqueObjectType to a String? [RESOLVED]
by Randy Lutcavich · in Torque X 2D · 10/17/2009 (10:17 pm) · 3 replies
How can I check what an object's type is?
If I have a bunch of enemies with different types how can I see what type they are in code? Is there are way to check their type against a string?
If I have a bunch of enemies with different types how can I see what type they are in code? Is there are way to check their type against a string?
About the author
Recent Threads
#2
just replace sprite with your object, and "enemy" with the type you want to check it against.
Edit: Guess I should have looked at the other linked thread first since it said the same thing. :)
10/18/2009 (10:20 am)
if (sprite.TestObjectType(TorqueObjectDatabase.Instance.GetObjectType("enemy")))
{
//Do something here based on whether this is the type I'm looking for
}just replace sprite with your object, and "enemy" with the type you want to check it against.
Edit: Guess I should have looked at the other linked thread first since it said the same thing. :)
Torque Owner Jake Davis
http://www.garagegames.com/community/forums/viewthread/61453
SceneObject has an ObjectType property but that does not seem to return what the object type actually is.