rotateto (pointing one object to another)
by Gavin Beard · in Torque Game Builder · 02/19/2009 (3:19 pm) · 3 replies
hi all
I have two objects within a simple scene, One is static, the other moves with user input. I've trying to get OBJECT1 (the static object) to point towards OBJECT2 (the moving object) in real time as OBJECT2 moves.
I thought maybe .rotateTo() was what i was looking for, but it seem to do a massive amount. i'm using code:
OBJECT1.rotateTo(OBJECT2.position,60);
but as i was the movement is very sporadic and never seems to point anywhere near the other object?
Is there anything i'm missing?
thanks
I have two objects within a simple scene, One is static, the other moves with user input. I've trying to get OBJECT1 (the static object) to point towards OBJECT2 (the moving object) in real time as OBJECT2 moves.
I thought maybe .rotateTo() was what i was looking for, but it seem to do a massive amount. i'm using code:
OBJECT1.rotateTo(OBJECT2.position,60);
but as i was the movement is very sporadic and never seems to point anywhere near the other object?
Is there anything i'm missing?
thanks
Torque 3D Owner Simon Jensen
SwiftThought Games
Here's a snippet I found that does the math pretty elegantly.