Guys I have an enemy of type KinematicBody2D which is supposed to follow player and stop at a certain distance when the player stops moving. Everything works and enemy follows player but when my player moves really slowly , the enemy starts to jitter very badly. I don't understand why ? Here's the code attached to the enemy :
var speed = 10000
onready var playerReference = get_parent().get_node("Player")
func _physics_process(delta: float) -> void:
var direction = playerReference.get_position() - position
var directionDistance = direction.length()
var normalizedDirection = direction.normalized()
look_at(playerReference.get_position())
if directionDistance > 80 and directionDistance <150:
move_and_slide(normalizedDirection*speed*delta)
The Enemy has AnimatedSprite, CollisionShape2D, Area2D as children. Also the player and the rest of the scene moves very smoothly, only enemy starts jittering when the player speed is slow. At high speed, the enemy also moves smoothly.