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()
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.
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.