Photon Quantum 3.0.0

Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Quantum.NavMeshPathfinder Struct Reference

The NavMeshAgent is an entity component for automated navmesh navigation and steering. Use NavMeshPathfinder.Create(FrameBase, EntityRef, NavMeshAgentConfig) to create pathfinder components. Also see NavMesh and NavMeshAgentConfig More...

Inheritance diagram for Quantum.NavMeshPathfinder:
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, AssetRef< NavMeshAgentConfig > configAssetRef, bool overwrite=true)
 Update the agent config during run-time. Will used default agent config from the SimulationConfig 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 from the SimulationConfig 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...
 
static void Serialize (void *p, FrameSerializer serializer)
 Callback to serialize this component into a snapshot of the game state. 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...
 
NavMeshRegionMask RegionMask
 Set individual region mask for this agent. 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...
 

Static Public Attributes

const int SIZE = 104
 The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed. 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...
 

Detailed Description

The NavMeshAgent is an entity component for automated navmesh navigation and steering. Use NavMeshPathfinder.Create(FrameBase, EntityRef, NavMeshAgentConfig) to create pathfinder components. Also see NavMesh and NavMeshAgentConfig

Member Function Documentation

◆ Create()

static NavMeshPathfinder Quantum.NavMeshPathfinder.Create ( FrameBase  f,
EntityRef  entity,
NavMeshAgentConfig  config 
)
inlinestatic

Use this factory to correctly initialize internals.

Parameters
fFrame
entityEntity
configAgent config
Returns
NavMeshPathfinder component that can be Set() on an entity

◆ IsOnLink()

bool Quantum.NavMeshPathfinder.IsOnLink ( FrameBase  f)
inline

Agent is active and is currently traversing a link.

Parameters
fFrame
Returns
true is waypoint is active, agent has waypoints and the current waypoint is a link end

Its current waypoint has the Navigation.WaypointFlag.LinkEnd flag.

◆ CurrentLink()

Int32 Quantum.NavMeshPathfinder.CurrentLink ( FrameBase  f)
inline

Returns the link that the agent currently is traversing.

Parameters
fFrame
Returns
Link index pointing into Navmesh.Links[] or -1

◆ CurrentWaypointHasFlag()

bool Quantum.NavMeshPathfinder.CurrentWaypointHasFlag ( FrameBase  f,
Navigation.WaypointFlag  waypointFlag 
)
inline

Test the current waypoint for a flag.

Parameters
fFrame
waypointFlagFlag to test for
Returns
true if the agent is active, has waypoints and if the current waypoint has the provided flag.

◆ GetWaypoint()

FPVector3 Quantum.NavMeshPathfinder.GetWaypoint ( FrameBase  f,
int  index 
)
inline

Get the waypoint position by waypoint index.

Parameters
fFrame
indexWaypoint index
Returns
3D waypoint position, zero if waypoint index is not valid

◆ GetWaypointFlags()

Navigation.WaypointFlag Quantum.NavMeshPathfinder.GetWaypointFlags ( FrameBase  f,
int  index 
)
inline

Access the waypoint flags by index.

Parameters
fFrame
indexWaypoint index (0..MaxWaypoints)
Returns
Mask of Navigation.WaypointFlag

◆ GetWaypointLink()

Int32 Quantum.NavMeshPathfinder.GetWaypointLink ( FrameBase  f,
int  index 
)
inline

Access the waypoint links by index.

Parameters
fFrame
indexWaypoint index (0..MaxWaypoints)
Returns
Link index pointing into in Navmesh.Links[] or -1

◆ SetConfig() [1/2]

void Quantum.NavMeshPathfinder.SetConfig ( FrameBase  f,
EntityRef  entity,
NavMeshAgentConfig  config,
bool  overwrite = true 
)
inline

Update the agent config during run-time. Uses the default config from the SimulationConfig when config is null.

Parameters
fFrame
entityAgent entity, required to forward the config to other agent components
configAgent config asset
overwriteReset 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.

◆ SetConfig() [2/2]

void Quantum.NavMeshPathfinder.SetConfig ( FrameBase  f,
EntityRef  entity,
AssetRef< NavMeshAgentConfig configAssetRef,
bool  overwrite = true 
)
inline

Update the agent config during run-time. Will used default agent config from the SimulationConfig if the provided asset ref can not be resolved. Internally calls SetConfig(FrameBase, EntityRef, NavMeshAgentConfig, bool).

Parameters
fFrame
entityAgent entity, required to forward the config to other agent components
configAssetRefAsset ref to navmesh config.
overwriteReset properties to their respective config values (e.g. NavMeshSteeringAgent.MaxSpeed, NavMeshAvoidanceAgent.Priority, ..)

◆ SetTarget()

void Quantum.NavMeshPathfinder.SetTarget ( FrameBase  f,
FPVector3  target,
NavMesh  navMesh 
)
inline

Set agent target position. Does nothing if the target is in NavMeshAgentConfig.StoppingDistance range.

Parameters
fFrame object
targetTarget position will be saved as Target and clamped to the grid as InternalTarget
navMeshThe 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.

◆ ForceRepath()

void Quantum.NavMeshPathfinder.ForceRepath ( FrameBase  f)
inline

Forces the agent to repath during the next Update(). Reset the waypoints and waypoint index internally.

◆ Stop()

void Quantum.NavMeshPathfinder.Stop ( FrameBase  f,
EntityRef  entity,
bool  resetVelocity = true 
)
inline

Stops the pathfinder agent immediately and disables it and resets its waypoints.

Parameters
fFrame
entityRequires the entity to check for the SteeringAgent
resetVelocityIf true it will check for a SteeringAgent component and set the velocity to zero

◆ Serialize()

static void Quantum.NavMeshPathfinder.Serialize ( void *  p,
FrameSerializer  serializer 
)
inlinestatic

Callback to serialize this component into a snapshot of the game state.

Parameters
pThe component pointer
serializerThe serializer

Member Data Documentation

◆ SIZE

const int Quantum.NavMeshPathfinder.SIZE = 104
static

The size of the component (or struct/type) in-memory inside the Frame data-buffers or stack (when passed as value parameter). Not related to the snapshot payload this occupies, which is bit-packed and compressed.

◆ RegionMask

NavMeshRegionMask Quantum.NavMeshPathfinder.RegionMask

Set individual region mask for this agent.

◆ ConfigId

AssetGuid Quantum.NavMeshPathfinder.ConfigId => _configId

Agent config asset.

Use see SetConfig(FrameBase, EntityRef, NavMeshAgentConfig, bool) to change config during runtime.

◆ InternalTarget

FPVector3 Quantum.NavMeshPathfinder.InternalTarget => _internalTarget

Target position is potentially corrected and moved inside the navmesh (read only).

◆ NavMeshGuid

AssetGuid Quantum.NavMeshPathfinder.NavMeshGuid => _navMeshID

Current assigned navmesh.

◆ Target

FPVector3 Quantum.NavMeshPathfinder.Target => _inputTarget

Input target position set by SetTarget(). (Read Only)

◆ WaypointIndex

int Quantum.NavMeshPathfinder.WaypointIndex => _waypointIndex

The current waypoint the agent steers towards or -1 if there are no stored waypoints.

◆ WaypointCount

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.

◆ WaypointMaxCount

int Quantum.NavMeshPathfinder.WaypointMaxCount => _waypointCapacity

The maximum number of waypoint that can be stored on the agent.

Defined by NavMeshAgentConfig.CachedWaypointCount.

Property Documentation

◆ IsActive

bool? Quantum.NavMeshPathfinder.IsActive
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.

◆ WaypointDetectionDistanceSqr

FP Quantum.NavMeshPathfinder.WaypointDetectionDistanceSqr
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