MY sprite when flips offests idk how to fix plz help

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tRobotic

the hit box is offset from the character the animation is on the left when the hitbox is on the right
here is my code

extends KinematicBody2D

const UP = Vector2(0,-1)
const GRAVITY = 20
const MAXSPEED = 80
const MAXGRAVITY = 200
const JUMPSPEED = 300
const ACCEL = 10

var movement = Vector2()
var facing_right = true

func _ready():

pass # Replace with function body.

func _physics_process(_delta):

movement.x = clamp(movement.x, -MAXSPEED,MAXSPEED)

if facing_right == true:
	$Sprite.scale.x = 1
else:
	$Sprite.scale.x = -1

if Input.is_action_pressed("left"):
	movement.x -= ACCEL
	facing_right = false
	$AnimationPlayer.play("Walk")
elif Input.is_action_pressed("right"):
	movement.x += ACCEL
	facing_right = true
	$AnimationPlayer.play("Walk")
else:
	movement.x = lerp(movement.x,0,0.2)
	$AnimationPlayer.play("idle")
if is_on_floor():
	if Input.is_action_just_pressed("jump"):
		movement.y = -JUMPSPEED

movement.y+= GRAVITY

if movement.y> MAXGRAVITY:
	movement.y=MAXGRAVITY
	
movement= move_and_slide(movement,UP)
:bust_in_silhouette: Reply From: exuin

An image of your sprite would help. But I bet the issue is that your sprite isn’t centered so when you flip it, the hitbox is off. Try changing the offset of your sprite and using the flip_h property to flip the sprite.