• 2D
  • Sprite flip

Hi, I have a sprite sheet where each sprite is not centered on each frame. When I use the flip method of the sprite, then the collision shape is misaligned to the sprite. This leads to incorrect collisions on my map. Left:

Right:

Since I am new to GODOT, can someone give me a tip how to handle this situation? Please note that I don't want to use different animation sequence for the left and right movement

I think the best solution is here is probably to scale the X axis to -1 to flip it. I do not remember if there are downsides/limitations to this method though, but I think that is what most projects do and what I have done in the past.

Hi,

As I remember I used offset property on sprite both with flip to align image better.

It worked well, but then you need to always set offset both with flip and remove it when turn off flip. Also you need to find what offset will be working the best in your case, so maybe scale X is easier solution, but that's probably another option if you need.

Thank you both. I'll try the scale and offset method and see which fits better to my needs

If you want to keep the sprite as unaltered as possible why not reposition the collision if you know where it's going to be when it flips? Seems silly to get all complicated about it by messing with the scale etc. unless there's something obvious here I'm missing. If you've made the collider a child of the sprite then it should continue follow as normal after the adjustment.

You could also make the Sprite a child of another Node2D. Then scale the x to -1 on the Node2D (not the Sprite) that way you can position it in the editor. In this case, the main parent object is not scaled or flipped, in case that messes with the collision.