Scripting API

Scripting API

NavMesh3D

Class in Abyss.Navigation, from Abyss.Navigation.

A navmesh: the floors an agent walks, baked from a scene's triangles (Bake) and loaded from what the bake made (Load), asked for a path between two points, the closest point of it to one, or how far a straight walk gets.

public sealed class NavMesh3D : IDisposable

Remarks

Each end is found on it within NavMesh3D.SearchExtents: a point a meter above the floor, where a character's middle is, finds the floor under it.

Areas, by their place in Project Settings ▸ Navigation (NavigationSettings): a path costs each meter of a floor its area's cost (SetAreaCosts), and crosses only the areas its mask ticks, a bit each but Not Walkable's: Walkable the lowest.

One thread at a time: a navmesh's search keeps its working state, so two systems that run together ask two navmeshes, or one after the other.

Properties

SearchExtents

public Vector3 SearchExtents { get; set; }

How far each way a point is looked for on the navmesh: a box half this size about it.

Polygons

public int Polygons { get; }

How many polygons it is made of.

Bounds

public (Vector3 Min, Vector3 Max) Bounds { get; }

The box it fills.

Methods

Bake

public static byte[] Bake(ReadOnlySpan<Vector3> vertices, ReadOnlySpan<int> triangles, in NavMeshBake3D settings)

Bakes a navmesh from a scene's triangles, in world space — vertices their corners, triangles three corners each, counter-clockwise seen from the side they face — for the agent settings says: what Load reads.

Parameters

  • vertices
  • triangles
  • settings

Exceptions

  • ArgumentException: The triangles are not three corners each.
  • InvalidOperationException: Nothing is walkable for the agent, or the bake failed, saying why.

Bake

public static byte[] Bake(ReadOnlySpan<Vector3> vertices, ReadOnlySpan<int> triangles, ReadOnlySpan<byte> areas, ReadOnlySpan<NavMeshBakeVolume3D> volumes, ReadOnlySpan<NavMeshBakeLink3D> links, in NavMeshBake3D settings)

Bakes a navmesh as Bake does, each triangle's floor of the area areas says by its place — Walkable for all where it is empty, Not Walkable a wall however flat — the floor within each of volumes its area, a later one's where they meet and Not Walkable's over all, and with links, ways across that a path crosses as it does a floor.

Parameters

  • vertices
  • triangles
  • areas
  • volumes
  • links
  • settings

Exceptions

  • ArgumentException: The triangles are not three corners each, or not one area each.
  • InvalidOperationException: Nothing is walkable for the agent, or the bake failed, saying why.

Load

public static NavMesh3D Load(ReadOnlySpan<byte> data)

A navmesh made of what a bake made.

Parameters

  • data

Exceptions

  • InvalidDataException: The bytes are no navmesh, or one of another version of Detour.

ClosestPoint

public bool ClosestPoint(Vector3 point, out Vector3 closest)

The point of the navmesh closest to point, within NavMesh3D.SearchExtents.

Parameters

  • point
  • closest

Returns Whether one is that close.

FindPath

public NavPath3D FindPath(Vector3 from, Vector3 to, int areaMask = -1)

A path from from to to along the navmesh, each end the closest point of it within NavMesh3D.SearchExtents, crossing only the areas areaMask ticks: its corners, or NavPath3D.None where either end is not that close to it.

Parameters

  • from
  • to
  • areaMask

FindPath

public int FindPath(Vector3 from, Vector3 to, Span<Vector3> corners, out bool partial, int areaMask = -1)

A path, as NavMesh3D.FindPath finds it, into corners, with nothing made: what a system asking every frame uses.

Parameters

  • from
  • to
  • corners
  • partial
  • areaMask

Returns How many corners it has, up to the room given; none where either end is not on the navmesh.

Raycast

public bool Raycast(Vector3 from, Vector3 to, out Vector3 hit)

Walks straight along the navmesh from from, the closest point of it, toward to: where a wall or the navmesh's edge stops it, in hit.

Parameters

  • from
  • to
  • hit

Returns Whether something stops it short; false where it gets there, or where it does not start on the navmesh.

Triangles

public Vector3[] Triangles()

Its triangles, to draw: three corners each.

Triangles

public Vector3[] Triangles(out byte[] areas)

Its triangles, to draw, three corners each, and each one's area by its place in areas.

Parameters

  • areas

SetAreaCosts

public void SetAreaCosts(ReadOnlySpan<float> costs)

Has a meter of each area cost what costs says, by its place — Walkable's first — in every path found on it and by every agent walking it from now on; each one not said costs 1. What NavigationSettings.AreaCosts gives.

Parameters

  • costs

Outline

public Vector3[] Outline()

Its outline, to draw: the edges no neighbor shares, two corners each.

InnerEdges

public Vector3[] InnerEdges()

The edges between its polygons, to draw: each once, two corners each.

Dispose

public void Dispose()

Frees it at once.

Constants

MaxCorners

public const int MaxCorners = 256

The most corners a path is found with by NavMesh3D.FindPath.

EveryArea

public const int EveryArea = -1

A mask of every area.