0 votes

I have a bunch of PNG images with the animation frames for an animated sprite.
Each image has different width and height.
How can I set where the pivot / anchor point is for each of these individual frames?
(It might be in different places for each frame.)

Inb4: I know how to set the pivot point for the entire sprite object.
What I'm asking about is setting the pivots of the indiviual frames.
Because now I see that they are always centered.
Or if I turn off centering, they are always pivoted to the top-left corner.
(Or whatever the "offset" parameter is set up to.)

in Engine by (64 points)

2 Answers

0 votes

As far as I can tell there is no such feature built into the node. If you want custom offsets per frame, you can do this pretty easily in script. Create an array of offsets that correspond to the frame number, and change it when the frame change is signaled.

This example is a two frame AnimatedSprite.

extends AnimatedSprite

func _ready():
    connect("frame_changed", self, "set_ofs")

var offsets = [Vector2(1000, 1000), Vector2(200, 200)]

func set_ofs():
by (5,248 points)
0 votes

I had the same issue. I created a node that contains all of the sprites.
I fine-tuned my sprites's offsets one-by-one.
The container node change visibility of frame (sprite node).
It can work with some sprites. I would not do that with more than 10 sprites.

For a huge amount of sprites.
I would export my sprite with a fixed border/space around the frame so all centered frame would look like fine.

by (313 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.