Struct NavMeshGraph
A simple NavMesh graph.
Inherited Members
Namespace: AnyPath.Graphs
Assembly: Assembly-CSharp.dll
Syntax
public struct NavMeshGraph : IGraph<NavMeshGraph.Location, NavMeshGraph.Segment>, IGraph, INativeDisposable, IDisposable
Constructors
| Improve this Doc View SourceNavMeshGraph(Vector3[], Int32[], NavMeshGraph.EnterCostAndFlags[], Matrix4x4, Allocator)
Construct a NavMesh from a set of vertices and triangles.
Declaration
public NavMeshGraph(Vector3[] vertices, int[] triangles, NavMeshGraph.EnterCostAndFlags[] enterCostAndFlags, Matrix4x4 localToWorldMatrix, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3[] | vertices | Vertices to use. Similar to how a Unity mesh is constructed. |
System.Int32[] | triangles | Triangle indices to use. Similar to how a Unity mesh is constructed. |
NavMeshGraph.EnterCostAndFlags[] | enterCostAndFlags | Array with cost and flags per triangle. Length should be the amount of triangles. (triangles array divided by 3) |
UnityEngine.Matrix4x4 | localToWorldMatrix | The local to world matrix to use. Use Matrix4x4.identity if the vertices are already in world space |
Unity.Collections.Allocator | allocator | Allocator to use |
NavMeshGraph(Vector3[], Int32[], Matrix4x4, Allocator)
Declaration
public NavMeshGraph(Vector3[] vertices, int[] triangles, Matrix4x4 localToWorldMatrix, Allocator allocator)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Vector3[] | vertices | |
System.Int32[] | triangles | |
UnityEngine.Matrix4x4 | localToWorldMatrix | |
Unity.Collections.Allocator | allocator |
Properties
| Improve this Doc View SourceTriangleCount
Amount of triangles contained in the mesh
Declaration
public readonly int TriangleCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Methods
| Improve this Doc View SourceCollect(NavMeshGraph.Location, ref EdgeCollector<NavMeshGraph.Location, NavMeshGraph.Segment>)
Declaration
public void Collect(NavMeshGraph.Location location, ref EdgeCollector<NavMeshGraph.Location, NavMeshGraph.Segment> collector)
Parameters
Type | Name | Description |
---|---|---|
NavMeshGraph.Location | location | |
EdgeCollector<NavMeshGraph.Location, NavMeshGraph.Segment> | collector |
Dispose()
Declaration
public void Dispose()
Dispose(JobHandle)
Declaration
public JobHandle Dispose(JobHandle inputDeps)
Parameters
Type | Name | Description |
---|---|---|
Unity.Jobs.JobHandle | inputDeps |
Returns
Type | Description |
---|---|
Unity.Jobs.JobHandle |
GetAdjecency(Int32, out Int32, out Int32, out Int32)
Returns the adjecent triangle indexes of a triangle.
Declaration
public void GetAdjecency(int triangleIndex, out int triangleIndex1, out int triangleIndex2, out int triangleIndex3)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | triangleIndex | The triangle's index to get the adjecent triangles from |
System.Int32 | triangleIndex1 | First adjecent triangle, -1 if none |
System.Int32 | triangleIndex2 | Second adjecent triangle, -1 if none |
System.Int32 | triangleIndex3 | Third adjecent triangle, -1 if none |
GetTriangle(Int32)
Returns a triangle by index
Declaration
public Triangle GetTriangle(int index)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | index | The index of the triangle |
Returns
Type | Description |
---|---|
Triangle |
Heuristic(NavMeshGraph.Location, NavMeshGraph.Location)
Estimated distance is based on the triangle's centers.
Declaration
public float Heuristic(NavMeshGraph.Location a, NavMeshGraph.Location b)
Parameters
Type | Name | Description |
---|---|---|
NavMeshGraph.Location | a | |
NavMeshGraph.Location | b |
Returns
Type | Description |
---|---|
System.Single |
RaycastNode(Ray, out NavMeshGraph.Location)
Performs a raycast against the NavMesh and returns the closest node that was hit. This can then be used as the starting node for a pathfinding request. The node contains information about the triangle as well as the exact location the path should start.
Declaration
public bool RaycastNode(Ray ray, out NavMeshGraph.Location location)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | ray | The ray to cast |
NavMeshGraph.Location | location | The node that can be used as part of a path finding request |
Returns
Type | Description |
---|---|
System.Boolean | True if there was a hit |
RaycastTriangle(Ray, out Triangle, out float3)
Performs a raycast against the NavMesh and returns the closest triangle that was hit.
Declaration
public bool RaycastTriangle(Ray ray, out Triangle triangle, out float3 hitPoint)
Parameters
Type | Name | Description |
---|---|---|
UnityEngine.Ray | ray | Ray to cast |
Triangle | triangle | The triangle that was hit |
Unity.Mathematics.float3 | hitPoint | The point where the triangle was hit |
Returns
Type | Description |
---|---|
System.Boolean | True if there was a hit |