Godot Version
v4.2.2
Question
get_next_path_position() always returns the enemy’s current position.
I’ve read some other posts and I understood this should be because I haven’t set a navigation layer on my tilemap but even after I added it, and painted the right tiles with it, the navigation agent still refuses to get the next position.
This is my code for navigation in the Enemy class:
var current_pos: Vector2 = global_position
var next_pos: Vector2 = navig_agent.get_next_path_position()
var new_velocity: Vector2 = current_pos.direction_to(next_pos) * speed
if navig_agent.avoidance_enabled:
navig_agent.set_velocity(new_velocity)
else:
_on_navigation_agent_2d_velocity_computed(new_velocity)
These are the settings on NavigationAgent2D and TileMap respectively:
I genuinely have no clue on why this doesn’t work yet