- Home /
Continuously Rotating Script?
Hi, I just needed the code to make a GameObject continuously rotate around on it's y axis throughout the whole game (preferably every 5-6 seconds is will reach 360 Degrees and start again if you know what I mean). Thanks, Dean.
i'm also looking for this, but i also want to move the objects from left to right, i'm using three rocks and i want it them to spin and move from left to right, i hope you can understand, i can't explain more b/c my English is so bad, Thank you in advance.
Answer by Bunny83 · Jun 07, 2012 at 11:51 AM
That's really easy:
var rotationsPerMinute : float = 10.0;
function Update()
{
transform.Rotate(0,6.0*rotationsPerMinute*Time.deltaTime,0);
}
what if we do not want to put it in the update function? I mean, i just wanna call the function once and it should continuously rotate it.
@idiot333 you can then in the Start() function set the torque to a rigidbody without it having angular drag: rigidbody2D.AddTorque(20);
Answer by dean_0707 · Jun 07, 2012 at 04:35 PM
Yes, This was exactly what I was looking for, I'm a beginner with Unity so it all seems pretty hard, thanks!