Continuous rotation via CoRoutine (C#)

Should be easy, right? I am at a loss here :frowning:

I just want to continuously rotate an object around it’s y axis in a CoRoutine. Do I have to use Quaternion.Slerp or Lerp instead of transform.Rotate?

public IEnumerator Explosion(gameObject go) {
		

        float speed = 100.0f;
	float lifeTime = Random.Range(0.4f, 0.8f);

	for (float t = 0.0f; t < lifeTime; t += Time.deltaTime) {
	     go.transform.Rotate(Vector3.up * speed * t, Space.Self);
            
	}
	 yield return null;
}

Rotate() is what you want, provide a pivot and an angle.

Unity ScriptReference: Transform.Rotate.html


Maybe this will clarify things (Adjust as needed):

IEnumerator SpinObject (GameObject go) {

	float duration = 30f;
	float elapsed = 0f;
	float spinSpeed = 1f;

	while (elapsed < duration)
	{
		elapsed += Time.deltaTime;
		go.transform.Rotate(Vector3.up, spinSpeed * Time.deltaTime);
		yield return new WaitForEndOfFrame();
	}

	yield return null;
}