Flipping CollisionShape2D with CharacterBody2D

Godot Version

4.2.2stable

I am having trouble with flipping collision.
I am trying to flip collision for a Characterbody2D and my sprite has a strange shape so I can’t just leave it where it is and I have no idea how to flip it with the CB2d. I am new and have been at this for hours with no luck…any advice would be great.
this is the scene tree
Screenshot 2024-07-24 at 6.00.58 PM

this is what it is doing currently

I had it flipping like this and attaching it to the collision itself, but if you hit both left and right together it would mess it up.

func _physics_process(delta):
if Input.is_action_just_pressed(“move_right”):
position.x *= 1
if position.x < 0 and Input.is_action_just_pressed(“move_right”):
position.x *= -1
if Input.is_action_just_pressed(“move_left”):
position.x *= -1
if position.x > 0 and Input.is_action_just_pressed(“move_left”):
position.x *= -1

Not sure if it means anything but this is what is in Characterbody2D right now to flip the sprite.

var direction = Input.get_axis(“move_left”, “move_right”)

	if direction:
		#emit_signal("flip")
		velocity.x = direction * SPEED
		if not jumping:
			current_state = WALKING
		if velocity.x > 0:
			sprite.flip_h = false
		elif velocity.x < 0:
			sprite.flip_h = true
			
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
		if not jumping:
			current_state = IDLE

Thanks in advance

Try putting your collision node under the player sprite. If that doesn’t work, then in your code, you can set the Scale.X value to (-1, 1). See if that works

1 Like