- Home /
Question by
Scott 10 · Apr 02, 2011 at 09:33 PM ·
rotationjavascripttimeslowing
Slowing rotation to a stop using Time.time
Hi all. I hope I have a easily solved scripting problem but it's a bit beyond my limited scripting talents right now. I just want to use a time function to slow an objects rotation to a stop.
Basically the object has a variable rotation that needs to be slowing over time. When it hits a certain low rotational threshold I want it to stop or in a future iteration call an animation that will make the object fall over and "die."
Here's what I have so far and a big thanks to anyone who can help me out.
//start rotate speed
var rotateStart = 300;
function Update ()
{
if (rotateStart >=30)
{
transform.Rotate (0,0,(rotateStart/(300*Time.time)));
}
else
{
transform.Rotate (0,0,0);
}
}
Comment
Your answer