- Home /
Animation with Transparency Floats Above Ground
I have a sprite animation of a character bobbing up and down. On the first frame, he is a certain height, X, then on the second frame, he is still height X. On the third and fourth frames of the animation, the sprite becomes smaller, taking up X - 1 pixels of space with one row of transparency taking up where there were colors before. On these third and fourth frames, the character floats off the ground, which is not desired. What is the solution to this? I would guess it is due to Unity drawing the sprite from the top-left corner and not recognizing it ought to draw the first row of transparent pixels.
Here is a reference image, although it is not my own.
Answer by VeryAnnoyingCat · Feb 23, 2021 at 04:28 PM
How are you exporting the images?
This is happening because the sprites on the 3rd and 4th frames are 1 pixel shorter than the 1st and 2nd.
Make sure that when you are exporting the images there is a line of transparent pixels on the top of the smaller sprites to make them equal to the other sprites.
If however you are importing from a sprite-sheet, make sure that the base lines match;
Feels bad man, I thought I had made sure the images were the right height - apparently the 3rd and 4th frames were one pixel shorter than they should have been. Pretty dumb oversight on my part, but thanks for the answer.