Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Master0987 |
Im trying to make the enemy follow the player. but every name i get a different error code
my scene hiarchy
Node2d
player(characterbody2d)
child: camera2d
Tilemap
navigation region 2d
enemy(characterbody2d)
child:NavigationAgent2d
my enemy code is
@export var targetlocationpath:NodePath
@onready var targetlocation:Node2D = getnode(“player”)
@onready var nav_agent = $NavigationAgent2D2
func ready():
navagent.settargetposition(targetlocation.globalposition)
func physicsprocess(delta):
if navagent.istargetreached():
var nextlocation = navagent.getnextposition()
var direction = globalposition.directionto(nextlocation)
global_position += direction * delta`