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 physicsprocess(_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)