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