I made an animation using the animation editor and noticed that when I play it in-game it looks wrong.
This is how it looks in the animation editor:
And this is how it looks in-game
This bug occurs both in studio playtest mode and in live games.
If you would like to see it for yourself: repro.rbxl (78.8 KB)
Open the rig with the animation editor and observe the SwordAttackRight animation.
Upload the animation from game.ServerStorage.RBX_ANIMSAVES.Rig.SwordAttackRight and set workspace.Rig.AnimationPlayer.Animation.AnimationId to that id.
Run the game and observe the animation looking weird.
Expected behavior
I expect the in-game animation to look the same as how it looks in the animation editor.
You need more keyframes, because animations always try to get to the next keyframe with the shortest path. Since rotation is Euler Angles in Roblox, this doesn’t always translate that well.
Animation editor must have some extra info or something because it always goes the path I intended and not the shortest.
Maybe this is a case of the default animation script playing alongside your animation? Be sure to check the keyframes and animation priority of your swing animation.
As of today, this is expected behavior. This discrepancy is due to an optimization made on the engine side for runtime playback of animations. In the Animation Clip Editor, the code displaying the motion will interpolate the two rotations within the keyframes using what’s called “Spherical Linear Interpolation” (Slerp), which will follow the shortest path between two rotations. At runtime, this interpolation is approximated as a “normalized linear interpolation” (Nlerp) to improve performance.
As a workaround, you can manually place intermediate keyframes between the two to reduce the error incurred by this approximation.
Thanks for the explanation! Would it be possible to make it so that Slerp is used instead of Nlerp when the animator is either in your character or is close to you?
unrelated but I’ve noticed a strange discrepancy on animations when they are on a rig using AnimationControllers versus when on a rig using Humanoids, rotation is correct but transformation/translation is significantly lessened on rigs with AnimationControllers. Is there a reason for this?