Smooth Rotation Possible?
by Hunter · in Torque X 2D · 03/18/2008 (12:08 pm) · 2 replies
Is there a way to make a smooth rotation of an object?
Currently im using actor.rotate = x; to rotate my player but it is an instant snap. I want a slow rotation over about 1/4 of a second. What is the easiest way to implement this?
Currently im using actor.rotate = x; to rotate my player but it is an instant snap. I want a slow rotation over about 1/4 of a second. What is the easiest way to implement this?
#2
03/20/2008 (7:28 am)
Use the SceneObject.angularvelocity variable (I'm at work so I don't have access to look up the exact name). The blaster tutorial uses this for turning I believe.
Torque Owner Brian Carter
// Rotate the object 45 degrees %myAngle = 45; // Use a delay that works best for you %theDelay = 10; for( %rotAngle = 0; %rotAngle <= %myAngle; %rotAngle++) schedule( %theDelay + (%theDelay * %rotAngle), 0, "rotateActor", %actor, %rotAngle); ...... function rotateActor( %actor, %angle ) { %actor.rotate = %angle; }You might need to fiddle with the parameters for schedule, but you get the idea (I hope). Not saying its the best way, but it should work in a pinch.