I ran into an issue recently in Godot 4.2.1 where the AnimationPlayer
doesn’t seem to interpolate the value of a shader parameter between key frames.
I verified that:
- The update mode of the track is set to
Continuous
.
- The interpolation mode of the track is set to
Linear
.
As you can see in the below example, the value of the Elapsed
parameter is still 0
despite the AnimationPlayer
playhead being halfway between two keys, which are set to the values 0
and then 0.5
.
I would expect to see the value set to 0.25
, but the value is still 0
. If I move the playhead to the end, the value is set to 0.5
. So, it appears interpolation is not working. Making tracks for other properties interpolates as expected. How do I get it to interpolate?
If you add a new key frame when the shader parameter is set to the default value, Godot actually emits a warning. For example:
scene/animation/animation_mixer.cpp:879 - AnimationMixer: ‘spin’, Value Track: ‘.:material:shader_parameter/elapsed’ uses a non-numeric type as key value with UpdateMode.UPDATE_CONTINUOUS. This will not be blended correctly, so it is forced to UpdateMode.UPDATE_DISCRETE. (User)
You can also see that the key frame is set to a null value instead of the default value if you hover over it instead of looking at the value of the key frame in the inspector:
Apparently, this is a tracked as #87040 in the Godot issue tracker and has not been fixed yet. To get around the issue, set the affected key frames to a non-default value. You can then set the value back to the default value in the inspector for the key frame. This will cause Godot to set a non-null value for the key frame.
Note: You have to set all key frames in all animations in order for this workaround to work. When I first tried doing this, I found that the interpolation for my animation still wouldn’t work because the RESET
animation still had a key frame with null values.
1 Like
does godot allow you to run events through the animation tracker? if so, you could run an event in there as well :Y
also throbber
I’m not sure what you mean by “event”, but you can indeed call methods from AnimationPlayer
. However, this would still not let interpolation happen automatically as the method would only be called once when the keyframe happens.
You could probably use that approach to work around the problem, but it would involve making the method implement its own interpolation inside a coroutine.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.