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.
smix8
August 25, 2024, 10:10am
2
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
smix8
August 25, 2024, 11:35pm
3
Made a PR for region queries.
godotengine:master
← smix8:region_point_query
opened 11:34PM - 25 Aug 24 UTC
Adds point and segment queries for regions, e.g. closet point, point normal, or … segment intersection.
Also updates the function documentation for the related map queries.
This gets added because quite frequently users voiced the need to do more local queries just on a single region instead of an entire navigation map.
Something to consider, a noticeable amount of this demand came from users that replaced their Geometry2D or physics queries with navigation queries as the API works better for their project needs. E.g. the Geometry2D class is unfriendly to query more complex polygons and physics has its own set of query limitations.
TODO (for other PR)
This PR duplicates some query code from the NavMap for the moment. The spatial queries should be moved out to a dedicated file and split to static functions, both to make them reusable and better for theads.
<!--
Please target the `master` branch in priority.
Relevant fixes are cherry-picked for stable branches as needed by maintainers.
To speed up the contribution process and avoid CI errors, please set up pre-commit hooks locally:
https://docs.godotengine.org/en/latest/contributing/development/code_style_guidelines.html
-->
1 Like
system
Closed
September 24, 2024, 11:35pm
4
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.