Godot interpolates the rotation between two animations "the wrong way"

Godot Version

4.4.1

Question

I am working on a game where the player character is represented by a 3D model with different animations for each of the states: idle, jump, fall, attack1… This model is made with Blender and imported as a .blend file into the engine.

I am having a problem when enabling Xfade between two of the animations, where the rotation for one of the bones in the character rotates de other way around. By that I mean that the bone instead of choosing the shortest path between the rotation values, it takes the further route and spins the other way around.

At first I assumed this was an issue with my animations in Blender, so I tried re-animating that bone with quaternions and Euler angles, but I kept getting the same behaviour.

(Funny enough, when I switched to Euler Angles, a similar issue showed up in Blender, but even when I fixed that, Godot was still reproducing it. I assume the model is force-converted to Euler angles automatically when exported to the engine)

Is there a way to change how, Godot handles the rotations of animations from skeletons? How could I fix my issue?

I have this same problem on Godot currently. Did you ever figure out a solution?

Use rotate_toward()

rotation = rotate_toward(rotation, target, rotation_speed * get_process_delta_time())

I animate 2D in Godot directly, which shows the same issue. Manually overring the keyframe value often fixes it (turn 181 into 179 for instance)

Using the recorder works better as well.

Of course, manually editing it means it will be overwritten again next import..

That’s what I had recently with a lighthouse beam as well.

The animation has to go from 0° to 90° to 180°, to 270° and then to 360° where it stops. Then the animation starts again from the beginning.

0° and 360° are the same position, but as animations are concerned, they are not the same value. Going from 270° to 0° is a -270° rotation. Not a 90° rotation.

I had same issue with my character’s wrist rotated the long way round. The fix was in Blender when you do the rotation of the pose. I had to make sure that the joints’ rotations were “clean” , that they did not contain any “residue angle” by Apply its rotation. And when set another pose I made sure that I rotate the joint cleanly with the shortest path. There should be no funny twisting / looping from the joint and the joints connected to it. (Sometimes it’s hard to notice that you made a mistake of actually twisted the joint full 360 first, or maybe some joint in that chain twist wrongly somehow).

I believe it could accumulate those residue angles from earlier poses as well like pose 1 to 2 rotates fine but pose 2 to 3 rotates wrongly so I had to make sure the joints’ rotation from pose 1 to 2 to 3 are clean and actually “flow” from one to another.

Anyway that was how I fixed it, going back the first pose then redo it cleanly. My suggestion therefore is to make an exact copy of the chain you want to do the Xfade blend then do the poses with a clean / short path rotation in Blender. Then you import it in to Godot to see if it does the Xfade rotation correctly. If it does then apply the same process to your model.