Godot Version
4.2.1 stable
Question
I have a weird problem: in my game i created an enemy who shoul follow the player with a navigationagent2d, this is the code:
func handle_movement():
$NavigationAgent2D.target_position = player.global_position
var direction =
to_local($NavigationAgent2D.get_next_path_position()).normalized()
velocity = direction * speed
with a navigationagent2d node set in the enemy scene tree; my game is made of different rooms (top-down arpg), all in the same level scene (different positions), and if i put my enemy in the first room it works fine. When i put it in the second room he activates and instead of following the player it goes in a straight line and is stuck in a wall (in doing so the debug line of the navigation agent doesn’t show up). When analizing what he is using as end point of the path (with get_final_position) the y coordinate updates correctly as the player moves, but the x coordinate is stuck and very far.
The tilemap is correctly set up for navigation (the floor tiles do have a navigation layer which is the same of the navigation agent), and every room has a different tilemap layer (i know this is not its typical use, but i did so for gameplay reasons) but navigation is enabled in all of them.
Do you have any idea what’s happening here?
Solved: I didn’t know there were different RIDs for navigation on different layers