When using a NavAgent2D, how can I get the closest point to a specific `NavRegion2D` that I choose programmatically?

Godot Version

4.3

Question

Title basically.

I have multiple rooms connected (each room has its own NavRegion2D on the floor), and when I hover my mouse over a room I’m playing an effect on the room borders. If I click on a spot on that room, regardless of where inside it that is, I want my player to move to the closest point in that room. This is to avoid the player moving to the upper floor because the mouse click happened close to the ceiling.

There is no real API for this for a single region only. The closest point query is for the entire navigation map.

So atm you would need to grab the region navigation mesh and check all the transformed polygons manually for the closest point.

1 Like

Made a PR for region queries.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.