| Parameter | Description |
|---|---|
| node | The first NavMesh node of the adjacent pair. |
| neighbor | The second NavMesh node of the adjacent pair. |
| left | One of the world points of the resulting separation edge. This point is the left side of the edge when traversing from the first node to the second. |
| right | One of the world points of the resulting separation edge. This point is the right side of the edge when traversing from the first node to the second. |
bool
true if a connection exists between the two NavMesh nodes.false if no connection exists between the two NavMesh nodes.
Obtains the end points of the line segment common to two adjacent NavMesh nodes.
For two polygons that are part of a NavMesh surface, this method returns the edge where both polygons meet. Any movement that crosses from one of the two nodes to the other passes through this edge. If the two polygons are in different NavMesh tiles, the connected edges can be of different length or have different start and end positions from each other. If this happens, the resulting separation edge is the overlapping part of the edges, which can be shorter than either of the individual edges.
When one node is a link and the other is a polygon, the returned points are placed where the link intersects the polygon.
The resulting positions are in world space. To transform them into a NavMesh's local space, use the inverse of the results from NavWorld.GetInstanceTransform.
Additional resources: NavWorld.GetEdgesAndNeighbors
using Unity.Collections; using UnityEngine; using Unity.AI.Navigation.LowLevel; public class PortalPointsExample : MonoBehaviour { void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation location = world.MapLocation(transform.position, Vector3.one, 0); if (!world.IsValid(location)) return; using NativeArray<NavNode> neighbors = new NativeArray<NavNode>(8, Allocator.Temp); using NativeArray<Vector3> vertices = new NativeArray<Vector3>(6, Allocator.Temp); using NativeArray<byte> edgeIndices = new NativeArray<byte>(neighbors.Length, Allocator.Temp); NavQueryStatus status = world.GetEdgesAndNeighbors(location.node, vertices, neighbors, edgeIndices, out int _, out int neighborCount); if ((status & NavQueryStatus.Success) == 0) return; // neighborCount reports every neighbor of the node, which can be more than the buffer // holds. A MoreDataAvailable flag tells you the remaining ones were dropped. int available = Mathf.Min(neighborCount, neighbors.Length); for (int i = 0; i < available; i++) { if (world.GetPortalPoints(location.node, neighbors[i], out Vector3 left, out Vector3 right)) Debug.DrawLine(left, right, Color.yellow); } } }