• 2D
  • How do you flip Collision Shapes?

So, flipping sprites is fine with me. I make a function that detects whether the player is moving left or right and sets "flip_h" to true or false accordingly. But doing this only affects the sprite, so I expect when I'll want to make my character hold objects and interact with the world in ways like that, this'll be an issue.

Basically I want to flip the entire player, not just it's sprite. How? Thanks in advance

Probably the easiest way to flip an entire set of nodes is to change the scale of the parent node to a negative number on the axis you wanting to flip. So to flip the player on the horizontal axis, something like this should, in theory, work:

# Flip everything on the X axis
self.scale.x *= -1
# Flip everything on the Y axis
self.scale.y *= -1

The only thing I'm not sure about is whether this will mess things up or not. I think it should work, from what I remember, but it might be negative scales do strange things.

Hopefully this helps! (Side note: welcome to the forums!)

Ah I've got a solution. Changing the scale of the parent of the sprite ends up doing weird stuff, it's not very reliable. Instead I can just make objects a child to the sprite, so they flip along with it. Obviously this doesn't work on the collision shape of the player but that's just something I'll put up with. Thanks