Photon Fusion 2.0.0

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, IAfterTick, IBeforeSimulation, and ISpawned.

Public Member Functions

void GetPlayerTickAndAlpha (PlayerRef player, out int? tickFrom, out int? tickTo, out float? alpha)
 Gets the tick and alpha interpolate values for a player.
 
int OverlapBox (BoxOverlapQuery query, List< LagCompensatedHit > hits, bool clearHits=true)
 Performs a lag-compensated box overlap query against all registered hitboxes. If the HitOptions.IncludePhysX or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
int OverlapSphere (SphereOverlapQuery query, List< LagCompensatedHit > hits, bool clearHits=true)
 Performs a lag-compensated sphere overlap query against all registered hitboxes. If the HitOptions.IncludePhysX or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
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.
 
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.
 
bool Raycast (RaycastQuery query, out LagCompensatedHit hit)
 Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
bool 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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
bool 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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
int RaycastAll (RaycastAllQuery query, List< LagCompensatedHit > hits, bool clearHits=true)
 Performs a lag-compensated raycast query against all registered hitboxes. If the HitOptions.IncludePhysX or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes.
 
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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes. Important: results are NOT sorted by distance.
 
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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity colliders are recommended for static geometry, rather than Hitboxes. Important: results are NOT sorted by distance.
 
- Public Member Functions inherited from SimulationBehaviour
virtual void FixedUpdateNetwork ()
 Fusion FixedUpdate timing callback.
 
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.
 
- Public Member Functions inherited from Behaviour
AddBehaviour< T > ()
 Wrapper for Unity's GameObject.AddComponent()
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren()
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent()
 
void AfterTick ()
 Called after each tick simulation completes.
 
void BeforeSimulation (int forwardTickCount)
 Called before both the re-simulation (when applicable) and forward simulation loops. Only called on updates that have forward ticks to process.
 
void Spawned ()
 Method to be called when an object is spawned.
 

Public Attributes

int BVHDepth
 Debug data from Broadphase BVH (tree depth).
 
int BVHNodes
 Debug data from Broadphase BVH (total nodes count).
 
LagCompensationDraw DrawInfo
 Debug data used to draw the BVH nodes and the lag compensation history.
 
int TotalHitboxes
 Debug data from lag compensation history (registered Hitbox count).
 

Additional Inherited Members

- Static Public Member Functions inherited from Behaviour
static void DestroyBehaviour (Behaviour behaviour)
 Wrapper for Unity's GameObject.Destroy()
 
- Properties inherited from SimulationBehaviour
bool CanReceiveRenderCallback [get]
 Gets a value indicating whether this instance can receive render callbacks.
 
bool CanReceiveSimulationCallback [get]
 Gets a value indicating whether this instance can receive simulation callbacks.
 
NetworkObject Object [get]
 The NetworkObject this component is associated with.
 
NetworkRunner Runner [get]
 The NetworkRunner this component is associated with.
 

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

◆ GetPlayerTickAndAlpha()

void GetPlayerTickAndAlpha ( PlayerRef  player,
out int?  tickFrom,
out int?  tickTo,
out float?  alpha 
)

Gets the tick and alpha interpolate values for a player.

Parameters
playerThe player reference.
tickFromThe tick value from which to interpolate.
tickToThe tick value to which to interpolate.
alphaThe interpolation alpha value.

◆ OverlapBox() [1/3]

int OverlapBox ( BoxOverlapQuery  query,
List< LagCompensatedHit hits,
bool  clearHits = true 
)

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

Parameters
queryThe query containing all necessary information.
hitsList to be filled with hits (both hitboxes and/or static colliders, if included).
clearHitsClear list of hits before filling with new ones (defaults to true).
Returns
The total number of hits found.

◆ OverlapBox() [2/3]

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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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 static 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) or Box2D (HitOptions.IncludeBox2D).
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() [3/3]

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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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 static 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) or Box2D (HitOptions.IncludeBox2D).
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/3]

int OverlapSphere ( SphereOverlapQuery  query,
List< LagCompensatedHit hits,
bool  clearHits = true 
)

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

Parameters
queryThe query containing all necessary information.
hitsList to be filled with hits (both hitboxes and/or static colliders, if included).
clearHitsClear list of hits before filling with new ones (defaults to true).
Returns
The total number of hits found.

◆ OverlapSphere() [2/3]

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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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 static 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) or Box2D (HitOptions.IncludeBox2D).
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() [3/3]

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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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 static 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) or Box2D (HitOptions.IncludeBox2D).
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/3]

bool Raycast ( RaycastQuery  query,
out LagCompensatedHit  hit 
)

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

Parameters
queryThe query containing all necessary information.
hitRaycast results will be filled in here.
Returns
The total number of hits found.

◆ Raycast() [2/3]

bool 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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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) or Box2D (HitOptions.IncludeBox2D).
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() [3/3]

bool 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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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) or Box2D (HitOptions.IncludeBox2D).
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/3]

int RaycastAll ( RaycastAllQuery  query,
List< LagCompensatedHit hits,
bool  clearHits = true 
)

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

Parameters
queryThe query containing all necessary information.
hitsList to be filled with hits (both hitboxes and/or static colliders, if included).
clearHitsClear list of hits before filling with new ones (defaults to true).
Returns
The total number of hits found.

◆ RaycastAll() [2/3]

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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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 static 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) or Box2D (HitOptions.IncludeBox2D).
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() [3/3]

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 or HitOptions.IncludeBox2D flag is indicated, query will also include static colliders, Unity 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 static 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) or Box2D (HitOptions.IncludeBox2D).
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