The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+3 votes

How can I change the frames of a sprite with sub-rectanges of different sizes?
VFrames and HFrames expect the spritesheet to have the same frame sizes, but my character goes beyond its 32x32 rect for some of its actions (It's just a frame change, not an actual "animation").

Currently my character rotates around itself to look at the mouse, but when I change its frame the center of rotation is wrong. Ideally I would set this center in a spritesheet like with the Unity3D sprite editor, but in Godot I don't know where to do that?

in Engine by (29,360 points)

What about resizing the whole thing so your bigger frame fits inside the range?

You could've posted it as answer ;)

I don't do that because it would create a lot of unused blank space in the texture, just because a few frames have elements going beyond 32px in size. Also, not only the size, but the center might change.

You ever figure out a good way of doing this?

I'm not working on the project requiring this currently, but my question still remains unanswered :/

2 Answers

+1 vote

I figured out a way to do this that isn't too tedius, you can use the auto slice tool on the spritesheet which gives you a bunch of region rects for each individual sprite the system detects.

Then you can create an animation with the rect region as the key and change the frames by clicking on the different auto detected regions.

by (34 points)

Where is this auto slice tool?
I thought of using AtlasTextures (which basically are texture sub-rectangles as a resource), but once set on sprites they don't retain their offset and you have to manually add it to AnimationPlayer, so can't even use AnimatedSprite on this

when you click on the sprite, on the bottom next to the animation tab a new option appears called "Texture Region"

Does anyone know how to do it for individual frames, in AnimatedSprite?

You can create AtlasTextures, those have a rect you can define by using slice tool. Then, you can load them in the AnimatedSprite animations. It's tedious though, but you need to do it anyways... if you use atlases.
If your textures are individual already, you don't need the slice tool, right?

0 votes

The way I did it was I created an AnimationPlayer. Then in the AnimationPlayer, each different animation has a keyframe for the AnimatedSprite's:

  • animation: change to the animation you want.
  • position: change so the center of that animation matches up to the center of the other animations in the AnimationSprite.

That way, you switch animations via the player, and it will choose the correct animation on the Sprite and reposition it so it looks like it matches up with the other frames.

by (14 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.