Top-Down Enemy Not Following Player

I recently entered a game jam and got a pretty good idea revolving around top down combat, but for some reason the basic enemy doesn’t follow the player properly. I’ve looked at several tutorials for top down enemies, but they all end up in the enemy making a beeline for the player, the enemy turning incredibly slowly, and when the enemy gets to the top left of the player, it stays fixed to an exact distance away from the player (I will attach an image of what happens in the replies). Help is appreciated!

(Tulip is the player, and I’ve already confirmed that the node path is correct)

extends CharacterBody2D

@onready var tulip = get_node("/root/Main/Tulip")

func _physics_process(delta):
	var direction = global_position.direction_to(tulip.global_position)
	velocity = direction * 100
	move_and_slide()

And what’s exactly the problem you’re having and what is it that you’d like to achieve?

I want the enemy to consistantly follow the player like in Vampire Survivors or something, but instead it just sticks a certain distance away in to the top left of the player, like this.


After it gets to a certain distance away from the player, the enemy only moves when the player does, and mimics the players movements.

Can you check if the local position of your collision shape and sprite Nodes of the player and enemy are 0, 0 in relation to their parent node?
Because the code you posted looks perfectly fine, the issue seems to be with the position of your Nodes.

1 Like

Turns out my player’s colision and sprite were just heavily offset from the nodes actually position, ty for telling me!

1 Like