Hey all

I wonder what is a better way to animate my character. I have everything kind of working, but the code is ugly and repetitive.

My character has many simple sprites. A few of them consists of modular body parts, while the rest are whole. These are not in a spritesheet, but individual .png's. As per the first pic attached, I add dozens of AnimatedSprite2D nodes to my character, each having its own sprite. I also have an AnimationPlayer with all the animations. Everything works great, except, ALL the sprites are shown at the same time so I have to manipulate the code to show/hide the sprites, depending on what the character is doing.

This is becoming tedious, as adding a new sprite/animation means I have to add conditions to address this new animation in so many areas of my code. I'm obviously doing it wrong and missing something simple.

I initially tried using just one AnimatedSprite2D node (second pic) with all the animations, but I can't use these meaningfully in the AnimationPlayer, especially with the 'modular' body parts. I also looked at the AnimationTree but this doesn't seem like it'll help, also looks like dealing with even more code.

The last pic shows what I need to do in code when the character is "falling" versus "grounded", and I have not even added all the other animations yet lol.



fire7side Hey thanks for the reply. I've been using the "Animations" area inside the AnimatedSprite2D node initially (as per my second pic) but this is not working as nicely as the AnimationPlayer because of all the modular bits in my character. Even when I forwent the modular bits as a test, by combining them, I found the AnimationPlayer animates the sprites a lot better/smoother.

I would still prefer to use a single AnimatedSprite2D node, as opposed to dozens (and counting) of them, but I can't add different tracks/animations of the same AnimatedSprite2D node to the AnimationPlayer, you can only use one from the looks of it. So I am unable to use only one AnimatedSprite2D node.

For now, I have shortened the code drastically, by creating functions for all that repeated code, but I still can't shake the feeling that what I'm doing is hilariously wrong and inefficient, and that the game will just crash with all the illogical code being flung around.