| Parameter | Description |
|---|---|
| node | The NavMesh node whose owner's transform to retrieve. |
| position | Outputs the world position of the NavMesh surface that owns the specified node. This is a zero vector when the NavMesh node is a NavMesh Link. |
| rotation | Outputs the world rotation of the NavMesh surface that owns the specified node. This is Quaternion.identity when the NavMesh node is a NavMesh Link. |
Retrieves the position and rotation of the NavMesh surface that contains the specified NavMesh node.
Unity defines the transform of a NavMeshData surface from the position and rotation values that you declare when you bake the surface with NavMeshBuilder.BuildNavMeshData, or as part of a NavMesh Surface, or when you explicitly set the values for NavMeshData.position and NavMeshData.rotation.
You can also specify custom transforms for NavMeshDataInstances when you create them, by passing explicit position and rotation values to the NavMesh.AddNavMeshData method.
Important: This method doesn't return the position and orientation of a single NavMesh polygon. It returns the position of the surface that owns the polygon.
Note: This method returns zero and identity instead of the actual transform for NavMesh Links that you instantiate with a call to NavMesh.AddLink.
Additional resources: NavWorld.GetNodeType
using UnityEngine; using Unity.AI.Navigation.LowLevel; public class InstanceTransformExample : MonoBehaviour { void Update() { using NavWorld world = NavWorld.GetDefaultWorld(); NavLocation location = world.MapLocation(transform.position, Vector3.one, 0); if (!world.IsValid(location)) return; world.GetInstanceTransform(location.node, out Vector3 surfacePosition, out Quaternion surfaceRotation); Debug.DrawRay(surfacePosition, surfaceRotation * Vector3.up, Color.yellow); } }