so ive been using lerp for my npc movement and his movement speed is set to a number and shouldn’t change I even made it a constant and it still changes speed based on player distance here is the npc and the code:
extends AnimatableBody2D
@onready var raycast = $RayCast2D
const MOVE_SPEED = 10
var inray = false
@onready var sprite = $AnimatedSprite2D
Called every frame. ‘delta’ is the elapsed time since the previous frame.
func _process(delta: float) → void:
var location: Vector2 = raycast.get_collision_point()
if raycast.is_colliding():
sprite.play(“run”)
position.x = lerp(position.x, location.x, delta * MOVE_SPEED)
if raycast.is_colliding() == false:
$AnimatedSprite2D.play("idle")
if location.x - position.x > 0:
sprite.flip_h = false
elif location.x - position.x < 0:
sprite.flip_h = true