Game Development Community

rotate objects and display

by cloudmm · in Torque 3D Beginner · 04/16/2010 (3:05 am) · 1 replies

Hi,everyone:
I have a problem,that how rotate ojects in game.
I write some codes as below,but it doesn't work. What's wrong?

$ballCount = 0;
function ballRotate()
{
ball.getTransform();
echo("The ball starts to rotate...");
if($ballCount%4 == 0)
{
ball.setTransform( "10 10 10 0 1 0 30");
Canvas.repaint();
echo(" ball.rotation:"@ball.rotation);
}
else if($ballCount%4 == 1)
{ ball.setTransform( "10 10 10 0 0 1 60");
Canvas.repaint();
echo(" ball.rotation:"@ball.rotation);
}
else if($ballCount%4 == 2)
{
ball.setTransform( "10 10 10 1 0 0 90");
Canvas.repaint();
echo(" ball.rotation:"@ball.rotation);
}
else if($ballCount%4 == 3)
{
ball.setTransform( "10 10 10 0 1 0 120");
Canvas.repaint();
echo(" ball.rotation:"@ball.rotation);
}
$ballCount++;

}
moveMap.bind( keyboard, R, ballRotate);


thanks,
cloudmm.

About the author

Recent Threads


#1
04/16/2010 (7:06 am)
For one, you are using degrees instead of radians. In worldbuilder you use degrees. In script, the transform angle is in radians.

ball.setTransform( "10 10 10 0 1 0" SPC mDegToRad(120) );

And then I'm not sure what you are trying to do with:
$ballCount%4

was the %4 appended by mistake?