Sprite2d frame width

Godot Version

Godot version 4.3

Question

I am trying to use another approach to make an animation_tree;I set a Sprite2d and using a png file for the texture propriety; according to its form i indicated Hframe and vFrame. The problem is thath the width os the section is too large… how could I set the appropriate width value??I dont see any field that stands for width…
Tanks in advance to who will help me.

You could set a region for the sprite, but if you want to use the basic sprite sheet features in godot you will need to have a uniform sprite sheet image, where each frame is exactly the same size.

ok, I see, I added rect and by click on Modify region I can select the various frame but also adter I select one of those and The resulting frame looks correct the x,y width and hength attributes are corrects but It is not what Is shown up on the screen…I dont know what is the mistake…

Could you show what you expected to happen versus what really happened? I don’t follow what you’ve done, modifying the region on a sprite2d should produce a visible result.

Make sure you have the sprite size set at least as big as the sprite region size.

Ok, basically I have a Sprite2d with Texture propriety set as:

Animation panel having these proprierties:
Hframes: 6
Vframes: 1

Region
Rect:
x: 108 y:12
w: 81 h:129

But thi is what is showen to me:

Using both region and hframes seems to be your issue. I would recommend cropping this sprite sheet, and ensuring the sprites are uniformly sized; it seems like the zombie has varying distance between each frame, and a lot of extra padding.

ok, but do you mean cropping the file in more files each for any sprite frame or maintaining all in the same file?

You could make seperate images for each frame, but I am recommending normalizing your empty space, notice your sprite has a little space at the start, then medium spaces, and a large end space (1, 2, 2, 2, 2, 3 widths) and a ton of empty space padding the bottom.

1 Like

The smallest rectangle that fits each character image is 84x132.
In a graphics editor create a grid of that size.
Cut and paste each character image into a cell of that grid
Choose a piece of the character that is immobile in the animation and use that to keep the image centered in each grid square.
The characters left foot seems to be planted in the same spot for each frame. It is the bottom-most point and two pixels back from the right-most point.
Use that to center your character.
Or just use this one that I made:

PS:
If this is the only thing on your sprite sheet you don’t need to enable the region. Just use the HFrames and VFrames values.

when I create new animation (e.g. walking) and set new image as texture, It happens the texture come back to another one I used for another animation…how should I manage the problem?.. :no_mouth:

You need to add a track with the texture as well. So the same way you added a track for the frame, you need to add a track with the key button next to the track property.

Mmm, about IDLE anim it has to be ruuned in loop; about walking animation I dont think… am i right???