AnimationPlayer2D is it possible to manipulate tracks via code?

Godot Version

4.2.1

Question

I’ve been searching a while but haven’t been able to get a straight answer. I have a Player scene with an AnimationPlayer2D node within it. My script flips the Sprite2D depending on direction input but there is a Marker2D node being animated to be always placed on my character’s hand. When I try to change it’s position directly via code it gets overwritten by the AnimationPlayer2D’s position track. Is there a way to simply access this track and give it a negative value when facing left?

image

You can change the animation by getting the Animation resource and using its methods to modify it. But it will be easier and less error prone if you add a Node2D node as a parent of your WeaponPos and move that Node2D via code.

1 Like

Good morning! This was definitely a simpler way of fixing my issue! Just had to change the father node’s position in order to be able to flip it, that made me have to remove any changes of the father’s position to the Marker2D but that was relatively quick. Thanks a lot for your help :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.