Flipping CollisionShape2D with Player sprite

I’m pretty new to godot, and I’m having trouble finding out how to flip my collision shape when i flip my sprite. hopefully you can help. This script is the movement for my player, which is only the movement template which I’m only editing

extends CharacterBody2D


const SPEED = 300.0
const JUMP_VELOCITY = -400.0
@onready var axer = $AnimatedSprite2D


func _physics_process(delta: float) -> void:
	# Add the gravity.
	if not is_on_floor():
		velocity += get_gravity() * delta

	# Handle jump.
	if Input.is_action_just_pressed("ui_accept") and is_on_floor():
		velocity.y = JUMP_VELOCITY

	var direction := Input.get_axis("ui_left", "ui_right")
	if direction:
		velocity.x = direction * SPEED
	else:
		velocity.x = move_toward(velocity.x, 0, SPEED)
	
	if direction > 0:
		axer.flip_h = false
	elif direction < 0:
		axer.flip_h = true

	move_and_slide()

There was a similar topic not too long ago, where it was answered here:

Maybe you can try the same solution.

1 Like

I just fixed it because someone helped on reddit. ty tho

How about posting the solution here, or at least a link to the reddit post?