How to get animation with different size frames to work?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By EGE00


I can’t find a clear solution to this problem. I have a death animation for an enemy pixel skeleton and I want it to stick to the floor during all frames, but on every frame except the biggest one the bone pile floats on the air and I have tried many things to fix this but nothing seems to work.

I really hope to get an answer and I thank in advance,

This doesn’t seem like a problem for Godot to solve. What are the dimensions of each of the animation frames? If you equalize them all using negative space, this shouldn’t be a problem anymore. I don’t know how that works with meshes though, I haven’t gotten into them at all.

Another option if you wanted to fix it in Godot alone would be to figure out the proper positional adjustment that needed to be done for each frame, and then connect your AnimatedSprite to its own frame_changed() signal. Each time it receives the signal, you have it check what the current animation and current frame is using get_animation() and get_frame(), then modify the AnimatedSprite’s position based on each individual frame’s needs.

denxi | 2020-02-23 03:15

:bust_in_silhouette: Reply From: Asthmar

I’ve ran into this problem before myself and as denxl said it’s something that’s better to fix outside of the engine
There are three things you can do

  1. Check for that death frame and, if it’s true it’s on that death frame (or the frame when the bones float) scale your sprite to where it needs to be in from the script. Then scale it back.

  2. Create another animated sprite that holds only the death animation. Make it a child of the main animated sprite. Position it and hide the death animation when it doesn’t need to be shown. And when you are showing it hide the other animated sprite.

  3. The most ideal thing to do would be to go to the art program and fix the sizes of the sprites because that’s the problem. The floating sprite doesn’t have the same negative space as the other sprites. If you ripped the sprites yourself then you may have cropped that specific frame to little, or if you created the sprites you just need to remove or add extra empty space.