Hi guys, I have a donut-shaped gameobject that starts spinning on its y axis when the player throws a switch. It works fine, but it doesn’t look very realistic (it’s a very large ring), so I was wondering if there was a way of scripting the spin to start slowly, with the ring building up its rotation speed over time until it reaches the max rotation rate and maintains it. Thanks for any assistance.
Cheers.
Try this:
var startSpeed = 1.0f;
var maxSpeed = 10.0f;
var increaseSpeed = 1.0f;
private var speed : float;
function Update() {
transform.Rotate(Vector3(0,Time.deltaTime*speed,0));
speed = Mathf.MoveTowards(speed, maxSpeed, Time.deltaTime * increaseSpeed);
}
That worked perfectly, exactly what I needed, thank you very much.