[Solved] Swapping animations moves the object?

I have a simple event system set up where when the player is in collision with the switch and the E button is pressed, to change the animation from “left” to “mid”. However, when I do this, the switch moves completely away from it’s original position.

Imgur: The magic of the Internet

How can I have the button/switches not move when the animation is changed?

It’s to do with the point of origin of the button. If you change it to the base of the button sprite (say bottom middle) it’ll be fine.

The sprite is placed at the same point for each animation. That sprite is made up of images. The position of the image in the animation relative to the origin will be different between animations. The image for unpressed will be lower than the image for pressed.

Thank you for the info! How would I go about changing the origin of the sprites?

In Sprite, under Animations, at the bottom you have “Points” button, you can change here the origin, and even add some other custom key points if you need them.

Okay I found it, though I’m not too sure how to adjust the point to fix the issue? If I move the point to the bottom of the object, it disappears on the next animation

The origin is where GDevelop place things, that’s why it looks to move.
Your origin should be on a place where you are sure it won’t “move” your animation to somewhere else.

On your case, each animation should have an origin on the center-bottom of your button.

Also it might help if you make your animations the same size because I read their answers above but can’t understand why changing the animations would make it jump around like that. Unless maybe they’re different sizes. Or the same size but framed incorrectly.

Sorry, I stand to be corrected on my previous post.

It sounds like you have the button images with the base at different levels/heights:

You can fix it 2 ways. Move the origin to the same spot of each button image (like the bottom left corner):

image and image

or keep the origin in the same spot, and change the buttom images so the base is at the same vertical level/position:

image and image

1 Like

I got it to work thank you!