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???

Hi, I set out a Sprite2D item and set Texture equal to the following image:

If I set on Sprite2d.Animation hframes:6 and vframes: 2 such that I could pick each frame but when I click on key+ icon for adding the next frame It remains the former frame, the 0th…What am i doing wrong??

I wouldn’t worry too much about the key+ functionality, if you change the playhead it will revert to the previous frame. Have you tried using an AnimatedSprite2D instead of a Sprite2D + AnimationPlayer?

Mmmm, I cannot understand the resason why If I set a Sprite2D whose Hframes and Vframes are equals to 6 and 2 respectively, Frame is set to 0 and I cannot change the value…

How are you trying to change the frame value? does it work with hframes or vframes other than 6 and 2? If you are using an AnimationPlayer are you sure that it’s stopped and not playing? or else it will overwrite any value you try to assign.

If you are using this image, then it still has a ton of padding at the bottom; 2 vframes will not look great.

Yes it is stopped

I tryed to set It = 4

Frame results equal to 0 and if i push on key+ icon to add next frame Is is always equal to 0

Maybe you should edit the animation keys in the Animation panel. Clicking on one of the track keys will open it in the inspector where you can change the value to any frame.

mmm, honestly i didn’t get you…