return value in coroutine for smooth rotation?


in order to use Coroutines, what should I return in the coroutine function if I want a smooth rotation?

This code works fine in the Update function, but it does not work in this coroutine : (the function does not seem to be repeated)

void OnTriggerEnter ( Collider other ) {
	StartCoroutine( startRot( other.transform ) );

IEnumerator startRot ( Transform p_other ){
	Quaternion newRotation = p_other.transform.rotation;
	transform.rotation = Quaternion.Slerp(transform.rotation, newRotation, Time.deltaTime*5);
	yield return 0;//1 : here?


Use yield return null. If you use yield return 0, it accomplishes the same thing, but performs allocations, so it should be avoided. (For Unityscript users, note that yield is the equivalent of yield return null, so you don’t have to worry about it.)

But the reason your coroutine doesn’t work is that it doesn’t really do anything. If you want smooth motion using Slerp, you need to repeatedly call it over time in a loop. You probably don’t want to use Time.deltaTime as the third parameter though.