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.
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}");
}
});
}