Move move_and_slide
before the is_on_wall
check:
func _physics_process(delta):
velocity.x = speed * direction
move_and_slide()
if is_on_wall():
direction *= -1
Move move_and_slide
before the is_on_wall
check:
func _physics_process(delta):
velocity.x = speed * direction
move_and_slide()
if is_on_wall():
direction *= -1