godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.58k stars 21.27k forks source link

Call Method in AnimationPlayer is spammed when setting current animation position in seek. #76773

Open TheFoxKnocks opened 1 year ago

TheFoxKnocks commented 1 year ago

Godot version

v4.0.2.stable.official [7a0977ce2]

System information

Windows 10

Issue description

Transitioning from two animations depending on player input, but maintining frame, is recommended to be coded like this (at least from what I've found):

anim_frame = anim.current_animation_position
if (input_vector):
    anim.play(str(character) + "/Run Attack")
else:
    anim.play(str(character) + "/Attack")
anim.seek(anim_frame)

Animation transitions fine, however I have a Call Method in the AnimationPlayer for these animations which is now spammed 20~30 times in quick succession.

Steps to reproduce

Set animation position and seek to that every frame and implement a Call Method into the animation. Call Method will be called multiple times.

Minimal reproduction project

Can be provided if requested.

smix8 commented 1 year ago

You properly have your method track key frame at time value 0.0 in the animation timeline.

The seek operation skips events between frame zero and seek position but it processes what is at those frames. Move your method track key frame a little further in the timeline like 0.05 to avoid the method call so the seek can properly jump over it.

TheFoxKnocks commented 1 year ago

No change, unfortunately. Makes sense, but if I do something like hold SHIFT and slide the Call Method over a little bit, it still spams it.