Here is the code
So im working on a shooter game and its my first one and im trying to make a ennemy that follows the player but im really struggling because instead of following the player it keeps the distance it innitially had with the player pls help
extends KinematicBody2D
var speed = 200
var motion = Vector2.ZERO
var player = null
func physicsprocess(delta):
motion = Vector2.ZERO
if player:
motion = position.directionto(player.position) * speed
motion = moveand_slide(motion)
func onArea2D2bodyentered(body):
player = body
func onArea2D2bodyexited(body):
player = null