Photon Fusion 1.1.6

Public Member Functions | Public Attributes | List of all members
HitboxManager Class Reference

Entry point for lag compensated Hitbox queries, which maintains a history buffer, and provides lag compensated raycast and overlap methods. Singleton instance is accessible through the property Runner.LagCompensation. More...

Inherits SimulationBehaviour.

Public Member Functions

override void FixedUpdateNetwork ()
 Internal use. Inserts (new ones) and updates all registered hitboxes into lag compensation history. More...
 
int OverlapBox (Vector3 center, Vector3 extents, Quaternion orientation, int tick, int? tickTo, float? alpha, List< LagCompensatedHit > hits, int layerMask=-1, HitOptions options=HitOptions.None, bool clearHits=true, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated box overlap query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. More...
 
int OverlapBox (Vector3 center, Vector3 extents, Quaternion orientation, int tick, List< LagCompensatedHit > hits, int layerMask=-1, HitOptions options=HitOptions.None, bool clearHits=true, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal)
 
int OverlapBox (Vector3 center, Vector3 extents, Quaternion orientation, PlayerRef player, List< LagCompensatedHit > hits, int layerMask=-1, HitOptions options=HitOptions.None, bool clearHits=true, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated box overlap query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. More...
 
int OverlapSphere (Vector3 origin, float radius, int tick, int? tickTo, float? alpha, List< LagCompensatedHit > hits, int layerMask=-1, HitOptions options=HitOptions.None, bool clearHits=true, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated overlap sphere query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. More...
 
int OverlapSphere (Vector3 origin, float radius, int tick, List< LagCompensatedHit > hits, int layerMask=-1, HitOptions options=HitOptions.None, bool clearHits=true, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal)
 
int OverlapSphere (Vector3 origin, float radius, PlayerRef player, List< LagCompensatedHit > hits, int layerMask=-1, HitOptions options=HitOptions.None, bool clearHits=true, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated overlap sphere query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. More...
 
void PositionRotation (Hitbox hitbox, int tick, out Vector3 position, out Quaternion rotation, bool subtickAccuracy=false, int? tickTo=null, float? alpha=null)
 Performs a lag-compensated query for a specific Hitbox position and rotation. More...
 
void PositionRotation (Hitbox hitbox, PlayerRef player, out Vector3 position, out Quaternion rotation, bool subTickAccuracy=false)
 Performs a lag-compensated query for a specific Hitbox position and rotation. More...
 
Boolean Raycast (Vector3 origin, Vector3 direction, float length, int tick, int? tickTo, float? alpha, out LagCompensatedHit hit, int layerMask=-1, HitOptions options=HitOptions.None, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. More...
 
Boolean Raycast (Vector3 origin, Vector3 direction, float length, int tick, out LagCompensatedHit hit, int layerMask=-1, HitOptions options=HitOptions.None, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal)
 
Boolean Raycast (Vector3 origin, Vector3 direction, float length, PlayerRef player, out LagCompensatedHit hit, int layerMask=-1, HitOptions options=HitOptions.None, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. More...
 
int RaycastAll (Vector3 origin, Vector3 direction, float length, int tick, int? tickTo, float? alpha, List< LagCompensatedHit > hits, int layerMask=-1, bool clearHits=true, HitOptions options=HitOptions.None, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. Important: results are NOT sorted by distance. More...
 
int RaycastAll (Vector3 origin, Vector3 direction, float length, int tick, List< LagCompensatedHit > hits, int layerMask=-1, bool clearHits=true, HitOptions options=HitOptions.None, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal)
 
int RaycastAll (Vector3 origin, Vector3 direction, float length, PlayerRef player, List< LagCompensatedHit > hits, int layerMask=-1, bool clearHits=true, HitOptions options=HitOptions.None, QueryTriggerInteraction queryTriggerInteraction=QueryTriggerInteraction.UseGlobal, PreProcessingDelegate preProcessRoots=null)
 Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. Important: results are NOT sorted by distance. More...
 
int ResolveQuery (ref Query query, List< LagCompensatedHit > hits, bool clearHits=true)
 Performs a raycast, raycast-all, sphere- or box-overlap query. Use the CreateQuery method of RaycastQuery, SphereOverlapQuery or BoxOverlapQuery, respectively, to create a query. More...
 
- Public Member Functions inherited from SimulationBehaviour
virtual void Render ()
 Post simulation frame rendering callback. Runs after all simulations have finished. Use in place of Unity's Update when Fusion is handling Physics. More...
 
- Public Member Functions inherited from Behaviour
AddBehaviour< T > ()
 Wrapper for Unity's GameObject.AddComponent() More...
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren() More...
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent() More...
 

Public Attributes

int BVHDepth
 Debug data from Broadphase BVH (tree depth). More...
 
int BVHNodes
 Debug data from Broadphase BVH (total nodes count). More...
 
int TotalHitboxes
 Debug data from lag compensation history (registered Hitbox count). More...
 
- Public Attributes inherited from SimulationBehaviour
NetworkObject Object
 The NetworkObject this component is associated with. May be null if this GameObject does not have a NetworkObject. More...
 
NetworkRunner Runner
 The NetworkRunner this component is associated with. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Behaviour
static void DestroyBehaviour (Behaviour behaviour)
 Wrapper for Unity's GameObject.Destroy() More...
 
- Properties inherited from SimulationBehaviour
bool CanReceiveCallback [get]
 
virtual bool? HasInputAuthority [get]
 Returns true if the Simulation.LocalPlayer of the associated NetworkRunner is the designated as Input Authority for this network entity. More...
 
virtual bool? HasStateAuthority [get]
 Returns true if the associated NetworkRunner is the State Authority for this network entity. More...
 
virtual bool? IsProxy [get]
 Returns true if the associated NetworkRunner is neither the Input nor State Authority for this network entity. It is recommended to use !HasStateAuthority or !HasInputAuthority when possible instead, as this check requires evaluating both authorities - and is therefore less performant than the individual checks. More...
 

Detailed Description

Entry point for lag compensated Hitbox queries, which maintains a history buffer, and provides lag compensated raycast and overlap methods. Singleton instance is accessible through the property Runner.LagCompensation.

Usage - Call any of the following methods:

HitboxManager.Raycast()
HitboxManager.RaycastAll()
HitboxManager.PositionRotation()
HitboxManager.OverlapSphere()

These methods use the history buffer to perform a Hitbox query against a state consistent with how the indicated PlayerRef perceived them locally.

Member Function Documentation

◆ FixedUpdateNetwork()

override void FixedUpdateNetwork ( )
virtual

Internal use. Inserts (new ones) and updates all registered hitboxes into lag compensation history.

Reimplemented from SimulationBehaviour.

◆ OverlapBox() [1/2]

int OverlapBox ( Vector3  center,
Vector3  extents,
Quaternion  orientation,
int  tick,
int?  tickTo,
float?  alpha,
List< LagCompensatedHit hits,
int  layerMask = -1,
HitOptions  options = HitOptions.None,
bool  clearHits = true,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated box overlap query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes.

Parameters
centerCenter of the box in world space.
extentsHalf of the size of the box in each dimension.
orientationRotation of the box.
tickThe exact tick to be queried
tickToSimulation tick number to use as the time reference for the lag compensation. If provided, must be combined with the alpha parameter for interpolation between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded value of alpha .
alphaInterpolation value when querying between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded alpha value.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
clearHitsClear list of hits before filling with new ones (defaults to true).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
The total number of hits found.

◆ OverlapBox() [2/2]

int OverlapBox ( Vector3  center,
Vector3  extents,
Quaternion  orientation,
PlayerRef  player,
List< LagCompensatedHit hits,
int  layerMask = -1,
HitOptions  options = HitOptions.None,
bool  clearHits = true,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated box overlap query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes.

Parameters
centerCenter of the box in world space.
extentsHalf of the size of the box in each dimension.
orientationRotation of the box.
playerPlayer who "owns" this overlap. Used by the server to find the exact hitbox snapshots to check against.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
clearHitsClear list of hits before filling with new ones (defaults to true).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
The total number of hits found.

◆ OverlapSphere() [1/2]

int OverlapSphere ( Vector3  origin,
float  radius,
int  tick,
int?  tickTo,
float?  alpha,
List< LagCompensatedHit hits,
int  layerMask = -1,
HitOptions  options = HitOptions.None,
bool  clearHits = true,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated overlap sphere query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes.

Parameters
originSphere center, in world-space
radiusSphere radius
tickThe tick to be queried
tickToSimulation tick number to use as the time reference for the lag compensation. If provided, must be combined with the alpha parameter for interpolation between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded value of alpha .
alphaInterpolation value when querying between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded alpha value.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
clearHitsClear list of hits before filling with new ones (defaults to true).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
total number of hits

◆ OverlapSphere() [2/2]

int OverlapSphere ( Vector3  origin,
float  radius,
PlayerRef  player,
List< LagCompensatedHit hits,
int  layerMask = -1,
HitOptions  options = HitOptions.None,
bool  clearHits = true,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated overlap sphere query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes.

Parameters
originSphere center, in world-space
radiusSphere radius
playerPlayer who "owns" this overlap. Used by the server to find the exact hitbox snapshots to check against.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
clearHitsClear list of hits before filling with new ones (defaults to true).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
total number of hits

◆ PositionRotation() [1/2]

void PositionRotation ( Hitbox  hitbox,
int  tick,
out Vector3  position,
out Quaternion  rotation,
bool  subtickAccuracy = false,
int?  tickTo = null,
float?  alpha = null 
)

Performs a lag-compensated query for a specific Hitbox position and rotation.

Parameters
hitboxThe target hitbox to be queried in the past
tickThe tick to be queried
tickToSimulation tick number to use as the time reference for the lag compensation. If provided, must be combined with the alpha parameter for interpolation between tick and tickTo . If subtickAccuracy is requested, the query will return the hitbox state interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded value of alpha .
alphaInterpolation value when querying between tick and tickTo . If subtickAccuracy is requested, the query will return the hitbox state interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded alpha value.
positionWill be filled with the hitbox position at the time of the tick
rotationWill be filled with the hitbox rotation at the time of the tick
subtickAccuracyIf the query should interpolate between ticks to reflect exactly what was seen on the client.

◆ PositionRotation() [2/2]

void PositionRotation ( Hitbox  hitbox,
PlayerRef  player,
out Vector3  position,
out Quaternion  rotation,
bool  subTickAccuracy = false 
)

Performs a lag-compensated query for a specific Hitbox position and rotation.

Parameters
hitboxThe target hitbox to be queried in the past
playerPlayer who "owns" this overlap. Used by the server to find the exact hitbox snapshots to check against.
positionWill be filled with the hitbox position at the time of the tick
rotationWill be filled with the hitbox rotation at the time of the tick
subTickAccuracyIf the query should interpolate between ticks to reflect exactly what was seen on the client.

◆ Raycast() [1/2]

Boolean Raycast ( Vector3  origin,
Vector3  direction,
float  length,
int  tick,
int?  tickTo,
float?  alpha,
out LagCompensatedHit  hit,
int  layerMask = -1,
HitOptions  options = HitOptions.None,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes.

Parameters
originRaycast origin, in world-space
directionRaycast direction, in world-space
lengthRaycast length
tickSimulation tick number to use as the time reference for the lag compensation (use this for server AI, and similar).
tickToSimulation tick number to use as the time reference for the lag compensation. If provided, must be combined with the alpha parameter for interpolation between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded value of alpha .
alphaInterpolation value when querying between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded alpha value.
hitRaycast results will be filled in here.
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
True if something is hit

◆ Raycast() [2/2]

Boolean Raycast ( Vector3  origin,
Vector3  direction,
float  length,
PlayerRef  player,
out LagCompensatedHit  hit,
int  layerMask = -1,
HitOptions  options = HitOptions.None,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes.

Parameters
originRaycast origin, in world-space
directionRaycast direction, in world-space
lengthRaycast length
playerPlayer who "owns" this raycast. Used by the server to find the exact hitbox snapshots to check against.
hitRaycast results will be filled in here.
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
True if something is hit

◆ RaycastAll() [1/2]

int RaycastAll ( Vector3  origin,
Vector3  direction,
float  length,
int  tick,
int?  tickTo,
float?  alpha,
List< LagCompensatedHit hits,
int  layerMask = -1,
bool  clearHits = true,
HitOptions  options = HitOptions.None,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. Important: results are NOT sorted by distance.

Parameters
originRaycast origin, in world-space
directionRaycast direction, in world-space
lengthRaycast length
tickSimulation tick number to use as the time reference for the lag compensation (use this for server AI, and similar).
tickToSimulation tick number to use as the time reference for the lag compensation. If provided, must be combined with the alpha parameter for interpolation between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded value of alpha .
alphaInterpolation value when querying between tick and tickTo . If HitOptions.SubtickAccuracy is included on options , this query will be resolved against hitbox colliders interpolated between the specified ticks. Otherwise, only one of the two ticks will be considered, according to the rounded alpha value.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
clearHitsClear list of hits before filling with new ones (defaults to true).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
total number of hits

◆ RaycastAll() [2/2]

int RaycastAll ( Vector3  origin,
Vector3  direction,
float  length,
PlayerRef  player,
List< LagCompensatedHit hits,
int  layerMask = -1,
bool  clearHits = true,
HitOptions  options = HitOptions.None,
QueryTriggerInteraction  queryTriggerInteraction = QueryTriggerInteraction.UseGlobal,
PreProcessingDelegate  preProcessRoots = null 
)

Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX flag is indicated, query will also include PhysX colliders, PhysX colliders are recommended for static geometry, rather than Hitboxes. Important: results are NOT sorted by distance.

Parameters
originRaycast origin, in world-space
directionRaycast direction, in world-space
lengthRaycast length
playerPlayer who "owns" this raycast. Used by the server to find the exact hitbox snapshots to check against.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
layerMaskOnly objects with matching layers will be checked against.
optionsOpt-in flags to compute with sub-tick accuracy (HitOptions.SubtickAccuracy) and/or to include PhysX (HitOptions.IncludePhysX).
clearHitsClear list of hits before filling with new ones (defaults to true).
queryTriggerInteractionTrigger interaction behavior when also querying PhysX.
preProcessRootsDelegate to pre-process HitboxRoots found in the broad-phase resolution of the query. Roots removed from the list will not be processed any further. Roots that remain on the candidates collection will be normally processed and fitting colliders will be evaluated in the query narrow-phase resolution. Hitbox collider indices added to the processed set will be evaluated in the narrow-phase regardless of further root processing steps (e.g. layer mask match).
Returns
total number of hits

◆ ResolveQuery()

int ResolveQuery ( ref Query  query,
List< LagCompensatedHit hits,
bool  clearHits = true 
)

Performs a raycast, raycast-all, sphere- or box-overlap query. Use the CreateQuery method of RaycastQuery, SphereOverlapQuery or BoxOverlapQuery, respectively, to create a query.

Parameters
queryThe lag-compensated query to be performed.
hitsList to be filled with hits (both hitboxes and/or PhysX colliders, if included).
clearHitsClear list of hits before filling with new ones (defaults to true).
Returns
The number of hits found by the query.
Exceptions
ArgumentExceptionIf the query type is not supported by this method.
var query = Fusion.LagCompensation.SphereOverlapQuery.CreateQuery(center, radius, Object.InputAuthority);
var hitCount = Runner.LagCompensation.Query(ref query, hits);
HitboxManager LagCompensation
Returns the global instance of a lag compensation buffer Fusion.HitboxManager.
Definition: NetworkRunner.cs:434
NetworkRunner Runner
The NetworkRunner this component is associated with.
Definition: SimulationBehaviour.cs:41
Definition: LagCompensation.Types.cs:5
Definition: Allocator.cs:7
Definition: LagCompensation.Types.cs:72

Member Data Documentation

◆ BVHDepth

int BVHDepth

Debug data from Broadphase BVH (tree depth).

◆ BVHNodes

int BVHNodes

Debug data from Broadphase BVH (total nodes count).

◆ TotalHitboxes

int TotalHitboxes

Debug data from lag compensation history (registered Hitbox count).