MoveTo() pains
by Stephen Triche · in Torque Game Builder · 06/23/2006 (8:21 am) · 4 replies
At the moment I'm trying to use moveTo() to rotate objects around a screen. The first problem I ran into is probably a common one, moveTo doesn't gurantee the object will reach its destination. So, of course, if I'm using a keyboard press to instigate the movement, if the button is pressed again before the movement is finished, everything get's all cerfluxxored (since these objects are suppose to exist in a rigid gridlike arrangement).
I've tried placing the code in a for statement that checks to make sure an object's current position is an appropriate starting point before instigating the moveTo, but if I go crazy on the controls I'm still able to knock some out of whack. Anyone know any good ways to deal with this? A way to check if an object is currently moving (without using the physics functions possibly). I saw the moveTo() function and thought it was perfect for a simple way to move an object on the screen, but the fact that I can interrupt it mid move with another moveTo() is causing problems.
I've tried placing the code in a for statement that checks to make sure an object's current position is an appropriate starting point before instigating the moveTo, but if I go crazy on the controls I'm still able to knock some out of whack. Anyone know any good ways to deal with this? A way to check if an object is currently moving (without using the physics functions possibly). I saw the moveTo() function and thought it was perfect for a simple way to move an object on the screen, but the fact that I can interrupt it mid move with another moveTo() is causing problems.
#2
06/23/2006 (8:53 am)
Glad to see that what I said actually made sense. Thats exactly what I was thinking. :D
#3
06/23/2006 (9:04 am)
One thing I learned the hard way is that you need to set appropriate margin of error for onPositionTarget if you want to get the callback to fire more consistently, the callback is well documented in the refererences.
#4
06/26/2006 (6:32 am)
Thanks much, totally forgot about those nifty callback functions. Much appreciated.
Torque 3D Owner Matthew Langley
Torque
if(!%obj.isMoving) { %obj.moveTo(..., ... etc); %obj.isMoving = true; }then onPositionTarget reset that flag
function objectClass::onPositionTarget(%this) { %this.isMoving = false; }