The NavMeshAgent is an entity component for automated navmesh navigation and steering. More...
Inherits Quantum.IComponent.
Public Member Functions | |
Int32 | CurrentLink (FrameBase f) |
Returns the link that the agent currently is traversing. More... | |
bool | CurrentWaypointHasFlag (FrameBase f, Navigation.WaypointFlag waypointFlag) |
Test the current waypoint for a flag. More... | |
void | ForceRepath (FrameBase f) |
Forces the agent to repath during the next Update(). Reset the waypoints and waypoint index internally. More... | |
FPVector3 | GetWaypoint (FrameBase f, int index) |
Get the waypoint position by waypoint index. More... | |
Navigation.WaypointFlag | GetWaypointFlags (FrameBase f, int index) |
Access the waypoint flags by index. More... | |
Int32 | GetWaypointLink (FrameBase f, int index) |
Access the waypoint links by index. More... | |
bool | IsOnLink (FrameBase f) |
Agent is active and is currently traversing a link. More... | |
void | SetConfig (FrameBase f, EntityRef entity, AssetRefNavMeshAgentConfig configAssetRef, bool overwrite=true) |
Update the agent config during run-time. Will used NavMeshAgentConfig.DEFAULT_ID if the provided asset ref can not be resolved. Internally calls SetConfig(FrameBase, EntityRef, NavMeshAgentConfig, bool). More... | |
void | SetConfig (FrameBase f, EntityRef entity, NavMeshAgentConfig config, bool overwrite=true) |
Update the agent config during run-time. Uses the default config (NavMeshAgentConfig.DEFAULT_ID) when config is null. More... | |
void | SetTarget (FrameBase f, FPVector3 target, NavMesh navMesh) |
Set agent target position. Does nothing if the target is in NavMeshAgentConfig.StoppingDistance range. More... | |
void | Stop (FrameBase f, EntityRef entity, bool resetVelocity=true) |
Stops the pathfinder agent immediately and disables it and resets its waypoints. More... | |
Static Public Member Functions | |
static NavMeshPathfinder | Create (FrameBase f, EntityRef entity, NavMeshAgentConfig config) |
Use this factory to correctly initialize internals. More... | |
Public Attributes | |
AssetGuid | ConfigId => _configId |
Agent config asset. More... | |
FPVector3 | InternalTarget => _internalTarget |
Target position is potentially corrected and moved inside the navmesh (read only). More... | |
AssetGuid | NavMeshGuid => _navMeshID |
Current assigned navmesh. More... | |
FPVector3 | Target => _inputTarget |
Input target position set by SetTarget(). (Read Only) More... | |
int | WaypointCount => _waypointCount |
The number of waypoints currently stored on the agent. More... | |
int | WaypointIndex => _waypointIndex |
The current waypoint the agent steers towards or -1 if there are no stored waypoints. More... | |
int | WaypointMaxCount => _waypointCapacity |
The maximum number of waypoint that can be stored on the agent. More... | |
Properties | |
bool? | IsActive [get, set] |
The active state of the agent. More... | |
FP | WaypointDetectionDistanceSqr [get, set] |
This value is used evaluate if a waypoint is reached and represents the squared distance an agent has traveled during the last tick. More... | |
The NavMeshAgent is an entity component for automated navmesh navigation and steering.
See also NavMesh and NavMeshAgentConfig
Example method that creates an entity with a transform, a view and a navmesh agent.
|
inlinestatic |
Use this factory to correctly initialize internals.
f | Frame |
entity | Entity |
config | Agent config |
|
inline |
Agent is active and is currently traversing a link.
f | Frame |
Its current waypoint has the Navigation.WaypointFlag.LinkEnd flag.
|
inline |
Returns the link that the agent currently is traversing.
f | Frame |
|
inline |
Test the current waypoint for a flag.
f | Frame |
waypointFlag | Flag to test for |
Get the waypoint position by waypoint index.
f | Frame |
index | Waypoint index |
|
inline |
Access the waypoint flags by index.
f | Frame |
index | Waypoint index (0..MaxWaypoints) |
|
inline |
Access the waypoint links by index.
f | Frame |
index | Waypoint index (0..MaxWaypoints) |
|
inline |
Update the agent config during run-time. Uses the default config (NavMeshAgentConfig.DEFAULT_ID) when config is null.
f | Frame |
entity | Agent entity, required to forward the config to other agent components |
config | Agent config asset |
overwrite | Reset properties to their respective config values (e.g. NavMeshSteeringAgent.MaxSpeed, NavMeshAvoidanceAgent.Priority, ..) |
Will set the config for NavMeshSteeringAgent and NavMeshAvoidanceAgent components on this entity as well.
This can trigger a repath when the waypoint count is changed.
|
inline |
Update the agent config during run-time. Will used NavMeshAgentConfig.DEFAULT_ID if the provided asset ref can not be resolved. Internally calls SetConfig(FrameBase, EntityRef, NavMeshAgentConfig, bool).
f | Frame |
entity | Agent entity, required to forward the config to other agent components |
configAssetRef | Asset ref to navmesh config. |
overwrite | Reset properties to their respective config values (e.g. NavMeshSteeringAgent.MaxSpeed, NavMeshAvoidanceAgent.Priority, ..) |
Set agent target position. Does nothing if the target is in NavMeshAgentConfig.StoppingDistance range.
f | Frame object |
target | Target position will be saved as Target and clamped to the grid as InternalTarget |
navMesh | The navmesh the agent uses during navigation |
Will reset the current waypoint list.
When the agent is currently on a link, the target position is saved but the waypoints are left intact. The current waypoint is then marked with Navigation.WaypointFlag.RepathWhenReached.
|
inline |
Forces the agent to repath during the next Update(). Reset the waypoints and waypoint index internally.
|
inline |
Stops the pathfinder agent immediately and disables it and resets its waypoints.
f | Frame |
entity | Requires the entity to check for the SteeringAgent |
resetVelocity | If true it will check for a SteeringAgent component and set the velocity to zero |
AssetGuid Quantum.NavMeshPathfinder.ConfigId => _configId |
Agent config asset.
Use see SetConfig(FrameBase, EntityRef, NavMeshAgentConfig, bool) to change config during runtime.
FPVector3 Quantum.NavMeshPathfinder.InternalTarget => _internalTarget |
Target position is potentially corrected and moved inside the navmesh (read only).
AssetGuid Quantum.NavMeshPathfinder.NavMeshGuid => _navMeshID |
Current assigned navmesh.
FPVector3 Quantum.NavMeshPathfinder.Target => _inputTarget |
Input target position set by SetTarget(). (Read Only)
int Quantum.NavMeshPathfinder.WaypointIndex => _waypointIndex |
The current waypoint the agent steers towards or -1 if there are no stored waypoints.
int Quantum.NavMeshPathfinder.WaypointCount => _waypointCount |
The number of waypoints currently stored on the agent.
The number of waypoints stored can be lower than the actual computed path (for performance reasons during copying the frame memory).
The first waypoint is always the agent position when the path finding triggered.
The last waypoint is a regular waypoint but a re-pathing is executed when the agent is steering toward it to reduce glitches during path recalculations.
int Quantum.NavMeshPathfinder.WaypointMaxCount => _waypointCapacity |
The maximum number of waypoint that can be stored on the agent.
Defined by NavMeshAgentConfig.CachedWaypointCount.
|
getset |
The active state of the agent.
Agent can be active and have no waypoints. That usually means, that the agent will try to find a path during the next tick.
|
getset |
This value is used evaluate if a waypoint is reached and represents the squared distance an agent has traveled during the last tick.
It is automatically set when the entity has NavMeshSteeringAgent
If not set the config value is used from NavMeshAgentConfig.DefaultWaypointDetectionDistance