Quaternion.RotateTowards() immediately snaps to target rotation

Hi, in the following code I want to roate an object with Quaternion.RotateTowards() inside the Update-Function. Unfortunately the Rotation doesn’t take place over a period of time but immediately snaps to the target position(goalRot). the target position is a public Quaternion Variable I set in the Inspector. For the movementSpeed I allready applied values between 0.1f and 10f, makes no different.

    if (rotateToWeight)
    {
        Debug.Log("rotation before: " + transform.rotation);

        // The step size is equal to speed times frame time.
        float step2 = movementSpeed * Time.deltaTime;

        transform.rotation = Quaternion.RotateTowards(transform.rotation, goalRot, step2 );
        Debug.Log("rotation: " + transform.rotation);
        Debug.Log("goalRot: " + transform.rotation);
        Debug.Log("Step: " + step2);

        // Check if Rotation finished
        if (gameObject.transform.rotation == goalRot)
        {
            // Stop Rotating
            rotateToWeight = false;

            Debug.Log("Finished ");
        }
    }  

The console prints the following:

rotation before: (-0.5, -0.5, -0.4, 0.6)
rotation: (-1.0, 0.0, 0.0, 0.0)
goalRot: (-1.0, 0.0, 0.0, 0.0)
Step: 0,09783585
Finished

So, obviousliy the target rotation is allready reached after the first call of the function. No idea why. I would be glad if someone could help

Do you have this code inside a loop in Update() ? I tried to replicate your situation and this was my result:

using UnityEngine;

public class RotateToQuaternionValue : MonoBehaviour
{
    public bool rotateToWeight = false;
    public Quaternion goalRotation = new Quaternion(-1.0f, 0.0f, 0.0f, 0.0f);
    public float speed = 50.0f;

    private void Update()
    {
        if (rotateToWeight)
        {
            float step = speed * Time.deltaTime;

            transform.rotation = Quaternion.RotateTowards(transform.rotation, goalRotation, step);

            if (transform.rotation == goalRotation)
            {
                rotateToWeight = false;
            }
        }
    }
}

This is placed on the object you want to rotate. And in the inspector this is what it looks like:143074-rotatequaternioninspector.png

Setting the bool starts the rotation and it turns off when it has reached the goalRotation value.
143075-rotatequaternion.gif

I hope this helps!