Class OffMeshLinks
Public
Manager for off-mesh links.
This manager tracks all active off-mesh links in the scene and recalculates them when needed. If an off-mesh link is activated, a LinkGraph will also be added to the graph list to store the special nodes necessary for the links to work.
Whenever a graph update happens, the DirtyBounds method should be called with the bounds of the updated area. This will cause the links touching that bounding box to be recalculated at the end of the graph update step.
Typically you will not need to interact with this class yourself, instead you can use the pre-built components like NodeLink2.
Inner Types
Public Methods
void
Add
(
)
Adds a new off-mesh link.
If any graphs change in the future, the link will automatically be updated to connect to the updated graphs.
Note
The link will not be added immediately, it will be added at the end of the current graph update step. Or, if no graph update is currently running, a graph update will be scheduled, and the link will be added at the end of that update. This is to avoid modifying the graph during a graph update.
List<NavGraph>
ConnectedGraphs
(
)
Get all graphs that this link is connected to.
Return
A list of all graphs that this link is connected to. This does not include the link graph. An empty list will be returned if the link is not connected to any graphs.
Note
For lower GC pressure, the returned list should be pooled after you are done with it. See: Pooling
void
Dirty
(
)
Mark a link as dirty.
This will cause the link to be recalculated as soon as possible.
void
DirtyBounds
(
)
Mark links touching the given bounds as dirty.
The bounds should contain the surface of all nodes that have been changed.
This will cause the links to be recalculated as soon as possible.
Note
Since graphs should only be modified during graph updates, this method should also only be called during a graph update.
Vector3 | point | Point to search around. |
float | maxDistance | Maximum distance to search. Use a small distance for better performance. |
)
Get the nearest link to a point.
Return
The nearest link to the point or a default OffMeshLinkTracer if no link was found. The returned struct contains both the link and information about which side of the link is closest to the point. If the end is closer than the start, then a reversed OffMeshLinkTracer will be returned.
void
Remove
(
OffMeshLinkSource | link | The link to remove. If the link is already removed, nothing will be done. |
)
Removes an existing off-mesh link.
Note
The link will not be removed immediately, it will be removed at the end of the current graph update step. Or, if no graph update is currently running, a graph update will be scheduled, and the link will be removed at the end of that update. This is to avoid modifying the graph during a graph update.
Public Enums
Directionality
OneWay |
Movement is only allowed from the start point to the end point.
|
TwoWay |
Movement is allowed in both directions.
|
Determines how a link is connected in the graph.
OffMeshLinkStatus
Inactive= 1 << 0 |
|
Pending= 1 << 1 |
|
Active= 1 << 2 |
|
FailedToConnectStart= Inactive | 1 << 3 |
|
FailedToConnectEnd= Inactive | 1 << 4 |
|
PendingRemoval= 1 << 5 |
|
Private/Protected Members