Skip to content

[Unity 6.2] Tween.RigidbodyMoveRotation and Tween.Custom<T, Quaternion> do not behave properly if the starting rotation is the same as the target rotation #197

@coty-crg

Description

@coty-crg

After upgrading from Unity 2022.3 to Unity 6.2, I noticed that our rotation tweens are sometimes broken. After some digging, it turns out that it only happens when the "start" and "end" rotations are equal, and it has something to do with PrimeTweens interpolation of Quaternions.

Quick examples:

public static Tween RigidbodyMoveRotation(UnityEngine.Rigidbody target, Quaternion rotation, TweenSettings settings)
{
    var startRotation = target.rotation;

    // correct: nothing changes (0, 0, -1)
    return Tween.Custom<Rigidbody>(target, 0f, 1f, settings, onValueChange: (Rigidbody target, float t) =>
    {
        if (target != null)
        {
            var targetRotation = Quaternion.Slerp(startRotation, rotation, t);
            target.MoveRotation(targetRotation.normalized);
            Debug.Log($"target.rotation: {target.rotation * Vector3.forward}, value: {targetRotation * Vector3.forward}, value.normalized: {targetRotation.normalized * Vector3.forward}");
        }
    });

    // incorrect: somehow ends up facing towards (1, 0, 0) 
    return Tween.Custom(target, target.rotation, rotation, settings, onValueChange: (target, value) =>
    {
        if (target != null)
        {
            target.MoveRotation(value.normalized);
            Debug.Log($"target.rotation: {target.rotation * Vector3.forward}, value: {value * Vector3.forward}, value.normalized: {value.normalized * Vector3.forward}");
        }
    });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions