My player is moving to the wrong position when using position2d. The code works as I want it to except that the player is moving a bit off from the correct position.

public override void _Ready() { bodyAnimation = GetNode<AnimatedSprite>("Body"); legsAnimation = GetNode<AnimatedSprite>("Legs"); totalMovePoints = GetNode("MovePoints").GetChildCount(); movePoints = GetNode("MovePoints"); target = movePoints.GetChild<Position2D>(currentTargetNumber).GlobalPosition; } public override void _PhysicsProcess(float delta) { if(!shouldMove) { shouldMove = true; if(currentTargetNumber == totalMovePoints - 1) { currentTargetNumber = 0; } else { currentTargetNumber += 1; } target = movePoints.GetChild<Position2D>(currentTargetNumber).GlobalPosition; } if((target - GlobalPosition).Length() < 2f) { GlobalPosition = target; shouldMove = false; } if(shouldMove) { MoveAndSlide((target - GlobalPosition).Normalized() * movementSpeed); } }