Game Development Community

Help with Code

by Danny Mejia · in Torque Game Builder · 09/21/2006 (10:41 am) · 6 replies

How do you check if in object is mounted to in other object. I know I can use the getMountedParnet() but, I need something this
if (object1.getMountedParnet() $= myObject)
{
do something
}

#1
09/21/2006 (11:50 am)
If that was copied and pasted than your problem is that you have Parnet instead of Parent

should be: getMountedParent()

if you don't need to know what it is mounted to but just that it is mounted to something use getIsMounted() which will return true or false.
#2
09/21/2006 (12:00 pm)
Ok here is what I have but its not working:

if(b1.getMountedParent() $= "b0_0")
{
if(r0.getRotation() == 90 && r1.getRotation() == 270)
{
b1.mount(b1_0,0,0,0,true,false,false);
}
}
#3
09/21/2006 (12:32 pm)
GetMountedParent is not likely to equal "b0_0". It's more likely to give you the object ID.

Try something like:
if (b1.getMountedParent() == myObject)
Where myObject is the name of the parent you're looking for.
#4
09/21/2006 (2:48 pm)
And if that doesn't work, try forcing the comparison of id

if (b1.getMountedParent().getId() == myObject.getId())
#5
09/21/2006 (2:49 pm)
B0_0 is the name
#6
09/21/2006 (2:57 pm)
Getmountedparent returns an object.
If you use B0_0 to compare it would not work.

Did you try Philip's or Ben's suggestion?