Set the position of an object
by CodingChris · in Torque Game Engine · 11/28/2006 (8:01 am) · 3 replies
Hi,
I want to set the position of an object called "ball" via script, but I don't really how to do.
My code is:
Please help.
I want to set the position of an object called "ball" via script, but I don't really how to do.
My code is:
function setball() {
%ball.position = "37 -414 -4";
}Please help.
About the author
#2
If you name your object "ball" in the level editor then you dont need %ball or $ball in front of it in the script file. If you want to carry out $ball.setTransform("x y z 0 0 0 0") in the console, then you need the $.
2) If you like, bind the setball() function to a key with in your /client/config.cs file, as follows:
BTW, not sure on the various ways to use setTransform(). It seems like there are a ton of ways to call it and pass arguments. Maybe someone could clarify on the easiest ways.
11/28/2006 (12:39 pm)
1) put your setball() function in /server/scripts/commands.cs. The code will be something like:function setball()
{
ball.setTransform("x y z 0 0 0 0");
}If you name your object "ball" in the level editor then you dont need %ball or $ball in front of it in the script file. If you want to carry out $ball.setTransform("x y z 0 0 0 0") in the console, then you need the $.
2) If you like, bind the setball() function to a key with in your /client/config.cs file, as follows:
moveMap.bindCmd(keyboard, "e", "commandToServer(\'setBall\');", "");
BTW, not sure on the various ways to use setTransform(). It seems like there are a ton of ways to call it and pass arguments. Maybe someone could clarify on the easiest ways.
#3
11/29/2006 (6:19 am)
Thanks now it works!
Torque 3D Owner Billy L
%ball.setTransform("37 -414 -4");