Game Development Community

MoveTo()

by David Taylor · in Torque Game Builder · 04/22/2006 (10:52 pm) · 5 replies

Has the moveTo() function been renamed? I know, for example, that setGroup() has since been changed to setGraphGroup(). Has something similar been done to moveTo()?

And if not, what is wrong with this code that generates a syntax error for me?

$marble.moveTo("30 20", 10, true, true, true, 0.01);

#1
04/23/2006 (1:05 am)
You forgot the quotes:
$marble.moveTo([b]"[/b]30 20[b]"[/b], 10, true, true, true, 0.01);
#2
04/23/2006 (1:43 am)
Thanks. Not sure how I missed them... :/
#3
04/23/2006 (12:02 pm)
Is there any way to pass variables to the desired moveTo location? I want the marble to end up where the cursor is.

Neither:
$marble.moveTo("$mouseObj.getPositionX() $mouseObj.getPositionY()", $marbleVelocityY, true, true, true, 0.01);

...nor:
$marble.moveTo($mouseObj.getPositionX(), $mouseObj.getPositionY(), $marbleVelocityY, true, true, true, 0.01);

...work. Alternatively, (and possibly even better), is it possible to simply rotate the sprite to face the cursor, and then tell it to move 'forward' on that angle?
#4
04/23/2006 (12:10 pm)
You need to compose the coordinates into a string, using string concatenation:

$marble.moveTo($mouseObj.getPositionX() @ " " @ $mouseObj.getPositionY()", $marbleVelocityY, true, true, true, 0.01);

(The @ symbol connects two strings together). Alternatively there's a shortcut concatenator, SPC, which is equal to @ " " @, so you could also have done $mouseObj.getPositionX() SPC $mouseObj.getPositionY() instead.
#5
04/23/2006 (12:15 pm)
Wow, you solved that pretty quickly and comprehensively, lol! Thanks, Luke! :)