if right == true:
$RayCast2D.position = -RayPosition
self.scale.x = -1
motion.x = 100
elif right == false:
$RayCast2D.position = RayPosition
self.scale = 1
The $RayCast2D was i fixed the issue but this would cause the same problem.
motion = move_and_slide(motion, up)
motion.y += 20
if Input.is_action_pressed("ui_right"):
self.global_scale.x = -4
if Input.is_action_pressed("ui_left"):
self.global_scale.x = 4
This was for testing purpose which caused the same issue.