A script used to calculate HyperNav paths.
More...
|
class | PropNames |
| This is used to refer to the names of private fields in this class from a custom Editor. More...
|
|
|
long | FindPath (Vector3 start, Vector3 end, HyperNavPathCallback receiver, float sampleRadius=0) |
| Find a path between two positions, and invoke the receiver when it is completed. More...
|
|
long | FindPath (NavHit startHit, NavHit endHit, Vector3 startPos, Vector3 endPos, HyperNavPathCallback receiver) |
| Find a path between two already-calculated nav query results, and invoke the receiver when it is completed. More...
|
|
void | CancelPath (long id, bool logError=true) |
| Cancel a pending path with the given ID. More...
|
|
|
virtual void | OnEnable () |
| If IsMainInstance is true, set MainInstance or log an error if it is already set. More...
|
|
virtual void | OnDisable () |
| Dispose the pools of pending paths and completed paths, and all memory allocated for pathfinding jobs. More...
|
|
virtual void | Update () |
| If mode is JobThread, check job completion. If mode is MainThreadAsynchronous, perform pathfinding work. More...
|
|
|
void | LateUpdate () |
| Move paths from the pending queue and start executing them. More...
|
|
A script used to calculate HyperNav paths.
Can be used as a singleton, or you can have more than one if needed.
◆ CancelPath()
void Infohazard.HyperNav.NavPathfinder.CancelPath |
( |
long |
id, |
|
|
bool |
logError = true |
|
) |
| |
Cancel a pending path with the given ID.
If the mode is set to JobThread and the requested path is already executing, the actual work thread cannot be cancelled. However, this will still remove the receiver, so no matter what that will not be called for the path.
- Parameters
-
id | The path ID to cancel. |
logError | Whether to log an error if the path is not running. |
◆ DisposePath()
void Infohazard.HyperNav.NavPathfinder.DisposePath |
( |
NavPath |
path | ) |
|
|
package |
◆ FindPath() [1/2]
Find a path between two already-calculated nav query results, and invoke the receiver when it is completed.
If pathfinding cannot occur, for example because there are no volumes, this method will return -1 and the receiver will not be invoked. If no path can be found, the receiver will be invoked with a null Path argument.
- Parameters
-
startHit | Query result for the start of the path. |
endHit | Query result for the end of the path. |
startPos | Start position for the path. |
endPos | Destination for the path. |
receiver | Callback to receive the path when it has been calculated. |
- Returns
- The ID of the pending path, or -1 if pathfinding cannot occur.
◆ FindPath() [2/2]
long Infohazard.HyperNav.NavPathfinder.FindPath |
( |
Vector3 |
start, |
|
|
Vector3 |
end, |
|
|
HyperNavPathCallback |
receiver, |
|
|
float |
sampleRadius = 0 |
|
) |
| |
Find a path between two positions, and invoke the receiver when it is completed.
If pathfinding cannot occur, for example because there are no volumes, or because a query at start or end fails, this method will return -1 and the receiver will not be invoked. If no path can be found, the receiver will be invoked with a null Path argument.
- Parameters
-
start | Start position for the path. |
end | Destination for the path. |
receiver | Callback to receive the path when it has been calculated. |
sampleRadius | Radius to search for volumes at the start and end locations./> |
- Returns
- The ID of the pending path, or -1 if pathfinding cannot occur.
◆ LateUpdate()
void Infohazard.HyperNav.NavPathfinder.LateUpdate |
( |
| ) |
|
|
private |
Move paths from the pending queue and start executing them.
◆ OnDisable()
virtual void Infohazard.HyperNav.NavPathfinder.OnDisable |
( |
| ) |
|
|
protectedvirtual |
Dispose the pools of pending paths and completed paths, and all memory allocated for pathfinding jobs.
◆ OnEnable()
virtual void Infohazard.HyperNav.NavPathfinder.OnEnable |
( |
| ) |
|
|
protectedvirtual |
◆ Update()
virtual void Infohazard.HyperNav.NavPathfinder.Update |
( |
| ) |
|
|
protectedvirtual |
If mode is JobThread, check job completion. If mode is MainThreadAsynchronous, perform pathfinding work.
◆ _isMainInstance
bool Infohazard.HyperNav.NavPathfinder._isMainInstance = true |
|
private |
(Serialized) Whether to set NavPathfinder.Instance to this instance.
◆ _maxCompletionFrames
int Infohazard.HyperNav.NavPathfinder._maxCompletionFrames = 3 |
|
private |
(Serialized) Maximum number of frames a job can take before the main thread must wait for it.
◆ _maxConcurrentJobs
int Infohazard.HyperNav.NavPathfinder._maxConcurrentJobs = 1 |
|
private |
(Serialized) Maximum number of pathfinding jobs that can be actively running at once.
◆ _maxExecutingRequests
int Infohazard.HyperNav.NavPathfinder._maxExecutingRequests = 0 |
|
private |
(Serialized) If greater than zero, limit on the number of requests actively being worked on.
◆ _maxPathOpsPerFrame
int Infohazard.HyperNav.NavPathfinder._maxPathOpsPerFrame = 100 |
|
private |
(Serialized) Maximum total number of pathfinding steps that can be performed per frame by this instance.
◆ _pathfindingMode
NavPathfindingMode Infohazard.HyperNav.NavPathfinder._pathfindingMode = NavPathfindingMode.JobThread |
|
private |
(Serialized) The mode to use for calculating paths.
◆ IsMainInstance
bool Infohazard.HyperNav.NavPathfinder.IsMainInstance |
|
getset |
Whether to set NavPathfinder.Instance to this instance.
This cannot be set while the game is running.
◆ MainInstance
The main instance, which should be used in most situations.
If you need more than one NavPathfinder, you can use direct references to other instances with IsMainInstance set to false.
◆ MaxCompletionFrames
int Infohazard.HyperNav.NavPathfinder.MaxCompletionFrames |
|
getset |
(JobThread Mode ONLY) Maximum number of frames a job can take before the main thread must wait for it.
Unity imposes a limit of 3 frames for faster TempJob allocations, so increasing this beyond 3 will slightly decrease memory performance. If a job takes longer than this and is forced to block the main thread, a warning will be logged showing you how long it blocked the main thread for. This cannot be set while any paths are executing.
◆ MaxConcurrentJobs
int Infohazard.HyperNav.NavPathfinder.MaxConcurrentJobs |
|
getset |
(JobThread Mode ONLY) Maximum number of pathfinding jobs that can be actively running at once.
Requests beyond this number are queued. You should keep this number fairly low, as each job has the potential to take up a CPU thread.
◆ MaxExecutingRequests
int Infohazard.HyperNav.NavPathfinder.MaxExecutingRequests |
|
getset |
(MainThreadAsynchronous Mode ONLY) If greater than zero, limit on the number of requests actively being worked on.
◆ MaxPathOpsPerFrame
int Infohazard.HyperNav.NavPathfinder.MaxPathOpsPerFrame |
|
getset |
(MainThreadAsynchronous Mode ONLY) Maximum total number of pathfinding steps that can be performed per frame by this instance.
This limit is shared by all executing paths in this instance.
◆ PathfindingMode
The mode to use for calculating paths.
This cannot be set while the game is running.
The documentation for this class was generated from the following file: