0
\$\begingroup\$

I was checking the new animation with that Mixamo right I made for combo attacks at various speeds.... and I realized I never thought about how implement it in-game.

Animation screenshot

Is there a simple, fast and straight forward method to just tell Godot "hey if this player has more attack speed %, then speed up this animation by that same %"?

\$\endgroup\$

1 Answer 1

3
\$\begingroup\$

You can set the custom_speed argument when calling play.

For example, to play an animation at half speed you do this:

$AnimationPlayer.play("animation_name", -1, 0.5)

Here custom_speed is 0.5 (i.e half speed).

The -1 is telling the AnimationPlayer to use the default blending between animations (these are blending times set in the transitions between animations, by default there is no blending, but you can configure them in the "Edit Transitions" option of the "Animation" menu in he "Animation" panel).


Or if you need more fine control, you can set the playback_process_mode to "Manual" so you can use seek and advance to advance the animation.


Be aware that AnimationPlayer in Godot 4 has a speed_scale property, and in Godot 3 it has a playback_speed, which you can use to make all the animations play faster or slower.

So if you cannot use the play method, you may react to the animation_started signal and set the speed_scale/playback_speed.


I have a couple extra tricks for you:

  • You can add a "Call Method Track" to your animation, and use it to set the speed_scale/playback_speed at the start of the animation. This won't work for animations from an imported scene (e.g. a gltf model), as you cannot modify those, so...
  • You can make an AnimationPlayer that plays animations from another AnimationPlayer using an "Animation Playback Track". So you can have another AnimationPlayer work as a proxy for the AnimationPlayer from the imported scene. Sadly this track does not let you set the speed either, but you might combine it with setting speed_scale/playback_speed from a "Call Method Track". With this you won't be able play multiple animations of the same animation player at the same time (for that you need an AnimationTree), but it might play multiple animations of multiple different AnimationPlayers in sync.

Sadly there is no way to control the playback speed from an AnimationTree. Also be aware that an AnimationTree could play multiple animations at the same time, so setting speed_scale/playback_speed might NOT work as desired.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .