To address the rotation issue when mixing animations with an empty animation, you can use the resetRotationDirections
method on the TrackEntry
. This method helps to reset the rotation directions, which can prevent the brief rotation error you are experiencing. Additionally, ensure that the shortestRotation
property is set appropriately to handle the rotation direction during mixing.
Here's how you can modify your code to include these adjustments:
public void StartPlaySpecialAni(AnimationReferenceAsset aimFirst, AnimationReferenceAsset aimSecond, bool aimLoop = false, bool aim2Loop = true) {
TrackEntry shootTrack = AnimationState.SetAnimation(1, aimFirst, aimLoop);
shootTrack.MixAttachmentThreshold = 1f;
shootTrack.SetMixDuration(0f, 0f);
AnimationState.AddEmptyAnimation(1, 1f, aimFirst.Animation.Duration);
Debug.Log(shootTrack);
TrackEntry aimTrack = AnimationState.SetEmptyAnimation(2, 0.1f);
aimTrack.resetRotationDirections(); // Reset rotation directions
aimTrack.shortestRotation = true; // Use shortest rotation direction
AnimationState.AddAnimation(2, aimSecond, aim2Loop, aimFirst.Animation.Duration);
aimTrack.MixAttachmentThreshold = 1f;
aimTrack.SetMixDuration(0f, 0f);
Debug.Log(aimTrack);
AnimationState.AddEmptyAnimation(2, 0.1f, aimSecond.Animation.Duration);
}
By resetting the rotation directions and ensuring the shortest rotation path is used, you can mitigate the rotation discrepancies when transitioning between animations.