Infohazard.HyperNav 1.1.5
3D Navigation for Flying Characters
Loading...
Searching...
No Matches
Infohazard.HyperNav.SplineNavAgent Class Reference

A script that can be used to calculate smooth paths by any entity that needs to use HyperNav for navigation. More...

Public Member Functions

override void Stop (bool abortPaths)
 Stop following the current path, and optionally cancel all path requests.
Parameters
abortPathsWhether to cancel pending path requests.
More...
 
- Public Member Functions inherited from Infohazard.HyperNav.NavAgent
virtual void Stop (bool abortPaths)
 Stop following the current path, and optionally cancel all path requests. More...
 
virtual void UpdatePath ()
 Request a new path from the current position to the desired destination. More...
 

Protected Member Functions

override void Update ()
 Updates measured velocity and finds the nearest point on the spline. More...
 
override void OnDrawGizmos ()
 Draws the current spline if NavAgent.DebugPath is true. More...
 
override Vector3 CalculateDesiredNavigationVelocity ()
 Calculate the velocity the agent wants to move in, in the range [0, 1]. More...
 
override void OnPathReady (long id, NavPath path)
 Callback that is received when a pathfinding request completes, which should start moving along that path.
Parameters
idThe id of the path request.
pathThe completed path, which is null if no path was found.
More...
 
override void OnDisable ()
 Stops all pathfinding and cancels path requests. More...
 
- Protected Member Functions inherited from Infohazard.HyperNav.NavAgent
virtual void Awake ()
 Sets the AvoidanceAgent.Infohazard.HyperNav.AvoidanceAgent.InputVelocityFunc. More...
 
virtual void OnEnable ()
 Resets MeasuredVelocity and sets Arrived to true. More...
 
virtual void OnDisable ()
 Stops all pathfinding and cancels path requests. More...
 
virtual void Update ()
 Updates measured velocity and current index in path. More...
 
virtual void OnDrawGizmos ()
 Draws the current path as a sequence of debug lines if DebugPath is true. More...
 
virtual Vector3 CalculateDesiredNavigationVelocity ()
 Calculate the velocity the agent wants to move in, in the range [0, 1]. More...
 
virtual void UpdateMeasuredVelocity ()
 Update the value of MeasuredVelocity, which is used to determine StoppingDistance. More...
 
virtual void UpdatePathIndex ()
 Update the current path index, which is used to determine NextWaypoint. More...
 
virtual void OnPathReady (long id, NavPath path)
 Callback that is received when a pathfinding request completes, which should start moving along that path. More...
 

Properties

float TangentScale [get, set]
 Scale to apply to spline tangents (lower values make the spline less curvy). More...
 
bool RaycastTangents [get, set]
 Whether to shorten tangents by raycasting to ensure they don't penetrate blocked areas. More...
 
int DistanceSamplesPerSegment [get, set]
 How many samples to take per segment of the spline when mapping the distance. More...
 
int DebugPointCount [get, set]
 If NavAgent.DebugPath is enabled, how many points to use to draw the curve. More...
 
float MaxAlignmentVelocityDistance [get, set]
 At what distance from the spline the agent will have all its desired velocity devoted to returning. More...
 
float CurvatureSampleDistance [get, set]
 Delta-T to use when sampling curvature (should be quite small). More...
 
float CurvatureOfMaxSlowdown [get, set]
 At what curvature value is the agent at its max curvature slowdown. More...
 
float MaxCurvatureSlowdown [get, set]
 The multiplier on desired tangent velocity when at the max curvature value. More...
 
bool DebugProjectOnSpline [get, set]
 Whether to draw debug lines when projecting on the spline. More...
 
float BlockedDetectionDistance [get, set]
 Distance in front of the agent to check to see if it needs to avoid level geometry. More...
 
float BlockedDetectionBackDistance [get, set]
 Distance behind the agent to check to see if it needs to avoid level geometry. More...
 
float BlockedDetectionMinSplineDistance [get, set]
 How far the agent must be from the spline to check for blocking level geometry. More...
 
SplinePath SplinePath [get]
 The spline that the agent is currently following. More...
 
float CurrentSplineParameter [get]
 The spline parameter value the agent is nearest to on the spline. More...
 
float CurrentSplineDistance [get]
 The distance along the spline the agent is nearest to. More...
 
float MaxSplineDistance [get]
 The length of the agent's current spline path. More...
 
- Properties inherited from Infohazard.HyperNav.NavAgent
float Acceptance [get, set]
 How close the agent must get to a destination before it is considered to have arrived. More...
 
float AccelerationEstimate [get, set]
 (Serialized) This should be set to the maximum acceleration of your agent. More...
 
float SampleRadius [get, set]
 The radius to search when finding the nearest NavVolume. More...
 
float DesiredSpeedRatio [get, set]
 The desired fraction of the maximum speed to travel at. More...
 
bool DebugPath [get, set]
 Whether to draw a debug line in the scene view showing the agent's current path. More...
 
bool KeepPathWhileCalculating [get, set]
 Whether to keep following the current path while waiting for a new path to finish calculating. More...
 
AvoidanceAgent AvoidanceAgent [get, set]
 AvoidanceAgent that this agent uses for avoidance (can be null). More...
 
bool ControlAvoidanceIsActive [get, set]
 If true, the Infohazard.HyperNav.AvoidanceAgent.IsActive state of the AvoidanceAgent is set based on whether there is a current valid path. More...
 
bool IsPathPending [get]
 Whether a path is currently in the process of being calculated for this agent. More...
 
virtual float StoppingDistance [get]
 The distance that it will take the agent to come to a stop from its current velocity, determined using the AccelerationEstimate. More...
 
Vector3 NextWaypoint [get]
 The current path waypoint that the agent is trying to move towards. More...
 
bool Arrived [get, private set]
 True if the agent has no active or pending path. More...
 
Vector3 Destination [get, set]
 Get or set the agent's destination (the position it is trying to get to). More...
 
Vector3 MeasuredVelocity [get, protected set]
 Velocity of the agent measured as delta position / delta time over the last frame, which is used to determine stopping distance. More...
 
NavPath CurrentPath [get, set]
 The current path that the agent is following. More...
 
float AvoidanceMaxSpeed [get, set]
 Maximum speed possible by this agent when avoiding obstacles. More...
 

Private Attributes

float _tangentScale = 0.5f
 (Serialized) Scale to apply to spline tangents (lower values make the spline less curvy). More...
 
bool _raycastTangents = true
 (Serialized) Whether to shorten tangents by raycasting to ensure they don't penetrate blocked areas. More...
 
int _distanceSamplesPerSegment = 5
 (Serialized) How many samples to take per segment of the spline when mapping the distance. More...
 
int _debugPointCount = 50
 (Serialized) If NavAgent.DebugPath is enabled, how many points to use to draw the curve. More...
 
float _maxAlignmentVelocityDistance = 1.5f
 (Serialized) At what distance from the spline the agent will have all its desired velocity devoted to returning. More...
 
float _curvatureSampleDistance = 0.01f
 (Serialized) Delta-T to use when sampling curvature (should be quite small). More...
 
float _curvatureOfMaxSlowdown = 0.5f
 (Serialized) At what curvature value is the agent at its max curvature slowdown. More...
 
float _maxCurvatureSlowdown = 0.5f
 (Serialized) The multiplier on desired tangent velocity when at the max curvature value. More...
 
bool _debugProjectOnSpline = false
 (Serialized) Whether to draw debug lines when projecting on the spline. More...
 
float _blockedDetectionDistance = 0.1f
 (Serialized) Distance in front of the agent to check to see if it needs to avoid level geometry. More...
 
float _blockedDetectionBackDistance = 0.1f
 (Serialized) Distance behind the agent to check to see if it needs to avoid level geometry. More...
 
float _blockedDetectionMinSplineDistance = 0.2f
 (Serialized) How far the agent must be from the spline to check for blocking level geometry. More...
 

Additional Inherited Members

- Events inherited from Infohazard.HyperNav.NavAgent
Action PathReady
 Invoked when the agent finds a path to the destination. More...
 
Action PathFailed
 Invoked when the agent fails to find a path to the destination. More...
 

Detailed Description

A script that can be used to calculate smooth paths by any entity that needs to use HyperNav for navigation.

A SplineNavAgent works just like (and is a subclass of) NavAgent. However, a SplineNavAgent feeds the path waypoints into a spline function to get a smoother path. In order to follow the spline, the SplineNavAgent creates its NavAgent.DesiredVelocity based on two factors:

  • Tangent: The direction the spline is pointing nearest the agent.
  • Alignment: The direction from the agent to the nearest point on the spline.

The agent will increase the influence of the alignment velocity the further it gets from the spline, in order to prevent drifting too far off. Additionally, the agent can slow down its desired tangent velocity on high-curvature regions, in order to take the curves more slowly.

Member Function Documentation

◆ CalculateDesiredNavigationVelocity()

override Vector3 Infohazard.HyperNav.SplineNavAgent.CalculateDesiredNavigationVelocity ( )
protectedvirtual

Calculate the velocity the agent wants to move in, in the range [0, 1].

Reimplemented from Infohazard.HyperNav.NavAgent.

◆ OnDisable()

override void Infohazard.HyperNav.SplineNavAgent.OnDisable ( )
protectedvirtual

Stops all pathfinding and cancels path requests.

Reimplemented from Infohazard.HyperNav.NavAgent.

◆ OnDrawGizmos()

override void Infohazard.HyperNav.SplineNavAgent.OnDrawGizmos ( )
protectedvirtual

Draws the current spline if NavAgent.DebugPath is true.

The spline will be drawn with DebugPointCount points.

Reimplemented from Infohazard.HyperNav.NavAgent.

◆ OnPathReady()

override void Infohazard.HyperNav.SplineNavAgent.OnPathReady ( long  id,
NavPath  path 
)
protectedvirtual

Callback that is received when a pathfinding request completes, which should start moving along that path.

Parameters
idThe id of the path request.
pathThe completed path, which is null if no path was found.

Reimplemented from Infohazard.HyperNav.NavAgent.

◆ Stop()

override void Infohazard.HyperNav.SplineNavAgent.Stop ( bool  abortPaths)
virtual

Stop following the current path, and optionally cancel all path requests.

Parameters
abortPathsWhether to cancel pending path requests.

Reimplemented from Infohazard.HyperNav.NavAgent.

◆ Update()

override void Infohazard.HyperNav.SplineNavAgent.Update ( )
protectedvirtual

Updates measured velocity and finds the nearest point on the spline.

Reimplemented from Infohazard.HyperNav.NavAgent.

Member Data Documentation

◆ _blockedDetectionBackDistance

float Infohazard.HyperNav.SplineNavAgent._blockedDetectionBackDistance = 0.1f
private

(Serialized) Distance behind the agent to check to see if it needs to avoid level geometry.

◆ _blockedDetectionDistance

float Infohazard.HyperNav.SplineNavAgent._blockedDetectionDistance = 0.1f
private

(Serialized) Distance in front of the agent to check to see if it needs to avoid level geometry.

◆ _blockedDetectionMinSplineDistance

float Infohazard.HyperNav.SplineNavAgent._blockedDetectionMinSplineDistance = 0.2f
private

(Serialized) How far the agent must be from the spline to check for blocking level geometry.

◆ _curvatureOfMaxSlowdown

float Infohazard.HyperNav.SplineNavAgent._curvatureOfMaxSlowdown = 0.5f
private

(Serialized) At what curvature value is the agent at its max curvature slowdown.

◆ _curvatureSampleDistance

float Infohazard.HyperNav.SplineNavAgent._curvatureSampleDistance = 0.01f
private

(Serialized) Delta-T to use when sampling curvature (should be quite small).

◆ _debugPointCount

int Infohazard.HyperNav.SplineNavAgent._debugPointCount = 50
private

(Serialized) If NavAgent.DebugPath is enabled, how many points to use to draw the curve.

◆ _debugProjectOnSpline

bool Infohazard.HyperNav.SplineNavAgent._debugProjectOnSpline = false
private

(Serialized) Whether to draw debug lines when projecting on the spline.

◆ _distanceSamplesPerSegment

int Infohazard.HyperNav.SplineNavAgent._distanceSamplesPerSegment = 5
private

(Serialized) How many samples to take per segment of the spline when mapping the distance.

◆ _maxAlignmentVelocityDistance

float Infohazard.HyperNav.SplineNavAgent._maxAlignmentVelocityDistance = 1.5f
private

(Serialized) At what distance from the spline the agent will have all its desired velocity devoted to returning.

◆ _maxCurvatureSlowdown

float Infohazard.HyperNav.SplineNavAgent._maxCurvatureSlowdown = 0.5f
private

(Serialized) The multiplier on desired tangent velocity when at the max curvature value.

◆ _raycastTangents

bool Infohazard.HyperNav.SplineNavAgent._raycastTangents = true
private

(Serialized) Whether to shorten tangents by raycasting to ensure they don't penetrate blocked areas.

◆ _tangentScale

float Infohazard.HyperNav.SplineNavAgent._tangentScale = 0.5f
private

(Serialized) Scale to apply to spline tangents (lower values make the spline less curvy).

Property Documentation

◆ BlockedDetectionBackDistance

float Infohazard.HyperNav.SplineNavAgent.BlockedDetectionBackDistance
getset

Distance behind the agent to check to see if it needs to avoid level geometry.

◆ BlockedDetectionDistance

float Infohazard.HyperNav.SplineNavAgent.BlockedDetectionDistance
getset

Distance in front of the agent to check to see if it needs to avoid level geometry.

◆ BlockedDetectionMinSplineDistance

float Infohazard.HyperNav.SplineNavAgent.BlockedDetectionMinSplineDistance
getset

How far the agent must be from the spline to check for blocking level geometry.

◆ CurrentSplineDistance

float Infohazard.HyperNav.SplineNavAgent.CurrentSplineDistance
get

The distance along the spline the agent is nearest to.

◆ CurrentSplineParameter

float Infohazard.HyperNav.SplineNavAgent.CurrentSplineParameter
get

The spline parameter value the agent is nearest to on the spline.

◆ CurvatureOfMaxSlowdown

float Infohazard.HyperNav.SplineNavAgent.CurvatureOfMaxSlowdown
getset

At what curvature value is the agent at its max curvature slowdown.

◆ CurvatureSampleDistance

float Infohazard.HyperNav.SplineNavAgent.CurvatureSampleDistance
getset

Delta-T to use when sampling curvature (should be quite small).

◆ DebugPointCount

int Infohazard.HyperNav.SplineNavAgent.DebugPointCount
getset

If NavAgent.DebugPath is enabled, how many points to use to draw the curve.

◆ DebugProjectOnSpline

bool Infohazard.HyperNav.SplineNavAgent.DebugProjectOnSpline
getset

Whether to draw debug lines when projecting on the spline.

◆ DistanceSamplesPerSegment

int Infohazard.HyperNav.SplineNavAgent.DistanceSamplesPerSegment
getset

How many samples to take per segment of the spline when mapping the distance.

◆ MaxAlignmentVelocityDistance

float Infohazard.HyperNav.SplineNavAgent.MaxAlignmentVelocityDistance
getset

At what distance from the spline the agent will have all its desired velocity devoted to returning.

◆ MaxCurvatureSlowdown

float Infohazard.HyperNav.SplineNavAgent.MaxCurvatureSlowdown
getset

The multiplier on desired tangent velocity when at the max curvature value.

◆ MaxSplineDistance

float Infohazard.HyperNav.SplineNavAgent.MaxSplineDistance
get

The length of the agent's current spline path.

◆ RaycastTangents

bool Infohazard.HyperNav.SplineNavAgent.RaycastTangents
getset

Whether to shorten tangents by raycasting to ensure they don't penetrate blocked areas.

◆ SplinePath

SplinePath Infohazard.HyperNav.SplineNavAgent.SplinePath
get

The spline that the agent is currently following.

◆ TangentScale

float Infohazard.HyperNav.SplineNavAgent.TangentScale
getset

Scale to apply to spline tangents (lower values make the spline less curvy).


The documentation for this class was generated from the following file: