0 votes

Hi, I searched in the documentation and I didn't find a way to do it. The thing is that in my game, the arms of the player are moved manually, so I need to temporary remove it´s keys from the animation player to do it, because if the keys from the arm are present, the arms will stop it´s movement and only do what the animation has predefined.
I know I could make different animations with and without the arms, but that would mean making a lot of different animations to do the action and that would break the order of the game.
So is there a way to delete specific keys from an animation with code?

asked Jan 10 in Engine by ArAdev (52 points)

1 Answer

+1 vote
Best answer

Yes, you can find it here: http://docs.godotengine.org/en/stable/classes/class_animation.html#class-animation-track-remove-key

You have to get the animation from the player, and then use the track functions as desired, giving the track index and the keyframe index. Should be the order that they appear, starting with 0.

var player = get_node("AnimationPlayer")
var anim = player.get_animation("my_anim_name")
anim.track_remove_key(track_idx, key_frame_idx)
answered Jan 10 by avencherus (4,305 points)
selected Jan 10 by ArAdev

Ok, I searched in the animation player section from the docs , and not from the animation section, this is very useful, thanks!

You're welcome. ^_^

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.