- Home /
Question by
OrestasSMK · Dec 13, 2017 at 11:25 AM ·
rotationrandomspeed
Decreasing object rotation speed until it stops?
Hi, i'm trying to write a script. I have a spinning wheel object and want it to rotate and every time to have random rotation length/time.
Now this it only spins with public Speed that i write in unity inspector.
public class rotation : MonoBehaviour
{
public float Speed = Random.Range(4f, 20f);
void Update()
{
if(Speed > 0)
{
transform.Rotate(0, Speed, 0);
Speed -= 1f * Time.smoothDeltaTime;
}
else
{
Speed = 0;
}
}
}
Comment
Your answer
Follow this Question
Related Questions
Random Speed to an Object Rotation 0 Answers
[Solved] How to calculate transition from movement speed to rotation speed? 1 Answer
2d move object relative to its rotation/place random on specified line? 0 Answers
Object Rotation/Character Speed 1 Answer
C# - How to vary rotation speed according to movement speed 1 Answer