Hello guys,
I've been trying to implement the navigation to work with the new TileMapLayer. Although I managed to exclude objects (Trees, objects, etc) from the NavigationPolygon, I ran into a weird issue where my character got stuck on the lines of NavigationPolygons.
I have a feeling I've done a wrong setup, and I would appreciate it if you could point me in the right direction.
Here's how I have the nodes setup and a simple picture of the problem:
Here is the code for the character navigation:
func _physics_process(delta:float) -> void:
var mouse_position:Vector2 = get_global_mouse_position()
if not Globals.nav_mesh_finished_baking:
print("returning")
return
navigation_agent_2d.target_position = mouse_position
var current_agent_position = global_position
print(current_agent_position)
var next_path_position = navigation_agent_2d.get_next_path_position()
print(next_path_position)
var new_velocity = current_agent_position.direction_to(next_path_position) * speed
print(new_velocity)
velocity = new_velocity
move_and_slide(
Let me know if you need a video of the problem or anything else. I'll make sure to provide it as soon as possible.