How to rotate about 360 on a coroutine

Hi everyone.

I can’t figure out the right way to rotate my object of 360 degrees in a coroutine… anyone can help me please?

Thank you in advance

Hi,
try this (you just have to start the coroutine):

IEnumerator Rotate(float duration)
{
    float startRotation = transform.eulerAngles.y;
    float endRotation = startRotation + 360.0f;
    float t = 0.0f;

    while ( t  < duration )
    {
        t += Time.deltaTime;

        float yRotation = Mathf.Lerp(startRotation, endRotation, t / duration) % 360.0f;

        transform.eulerAngles = new Vector3(transform.eulerAngles.x, yRotation, 
        transform.eulerAngles.z);

        yield return null;
    }
}

Hey! Its pretty weird and tricky question but I think the best way will be using iTween asset that helps you with movement and rotations. Its completly free and easy to use. Also its a good tool to use it instead of animations. For example if you got something simple like button moving on X axis etc. you can tween it instead of creating animator, animator controller. Its much lighter for compiling.

I did it with Transform.Rotate, then check the quaternion angle, and when it reach the target the loop will stop.

That’s all.