+1 vote

Been playing around with this, and it seems like there isn't any built-in way to set the pivot point location relative to the Sprite. It's new position also becomes the pivot point, and the texture will jump.

It's been a bit of an issue when Sprites are rotated or in a tree of Sprites that also have rotations.

in Engine by (5,232 points)

Could you provide an example?
I have an vague idea of what you are having a problem with, but the room for misunderstanding is too great at the moment.

If you have a centered Sprite at location (0,0) it will sit centered in the scene's origin. If in script, in my case using tool mode, if you use either of the following:

var s = get_node("my_sprite")
s.set_offset(Vector2(0,32))

or using the edit_set_pivot() from the node methods, you will see that the pivot/offset is at the origin now, however the sprite image will have moved down 32 pixels.

It's not that it's moving down exactly, it's just that when you use the V key to set pivots, it will adjust a new relative position of the sprite so it preserves where your Sprite visually appeared.

Okay, I understand.

I have experienced that using the "tool" property on the top of some scripts can screw things up inside it. Have you tried to run it without tool?

An alternative to using setoffset, is to create another node (could name it pivotnode), and put the mysprite node inside it. That way, the sprite will be relative to the pivotnode and you can just set the normal position of the sprite to be 0,32 away from it.

Would that work for you?

The tool is working fine. The offset is even working as designed.

I'm going to use these for bones.

I may try that out if it becomes too difficult to calculate a more direct solution by calculating normals based on the rotations. I'll have to see if that even works.

If not, yeah I guess it's probably not too terrible to fill some Position2Ds in between the Sprites.

1 Answer

0 votes

Dude, You are aware that you can change position, scale, even spritesheet in animation player , right ? So you can adjust offset in animation player by moving sprite and keying it .
I have offset different per animation, so i key my animationsheets and position on first frame of every animation, cause i swap spritesheets when changing anims, its really great

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 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 webmaster@godotengine.org with your username.