Prevent Specific Track Value Interpolation When Blending Animations in BlendTree

Godot Version

Godot-4.7.1-.NET

Question

I use the texture_offset property of a Polygon2D node to switch between different facial expressions for a character. Each expression corresponds to a fixed texture_offset value, and all character expressions are stored on a single large texture atlas.

For the RESET animation of the AnimationPlayer node, the texture_offset property value of the “Face” Polygon2D node is:

image

The property value on the attack animation is:

image

Both animation tracks use Discrete mode:

When blending these two animations using AnimationTree’s BlendTree, the face exhibits a sliding movement effect. I believe this happens because BlendTree interpolates the tracks for the same property across the two animations, which is not the behavior I want. I want the character’s facial expression to switch instantly. How can I achieve this? Preferably solved at the animation editing level without writing any code.

ezgif-196b93c4f38d797b

AnimationTree overrides AnimationMixer.callback_mode_discrete and forces all tracks with Animation.UpdateMode.DISCRETE to be treated as Animation.UpdateMode.CONTINUOUS

Set the value to AnimationMixer.AnimationCallbackModeDiscrete.ANIMATION_CALLBACK_MODE_DISCRETE_DOMINANT