Photon Fusion 1.1.2

Public Member Functions | Public Attributes | Static Public Attributes | Protected Member Functions | Properties | List of all members
HitboxRoot Class Reference

Root Hitbox group container. Manages registering/unregistering hitboxes with the group, and defines the broadphase geometry for the group. More...

Inherits NetworkBehaviour.

Public Member Functions

void OnDrawGizmos ()
 
void InitHitboxes ()
 Finds child Hitbox components, and adds them to the Hitboxes collection. More...
 
void SetMinBoundingRadius ()
 Sets BroadRadius to a rough value which encompasses all Hitboxes in their current positions. More...
 
void SetHitboxActive (Hitbox hitbox, bool setActive)
 Sets the state of a Hitbox instance under this root. Both the hitbox and its root must be active in order for it to be hit by lag-compensated queries. More...
 
bool IsHitboxActive (Hitbox hitbox)
 Checks the state of a Hitbox instance under this root. Both the hitbox and its root must be active in order for it to be hit by lag-compensated queries. More...
 
override void Despawned (NetworkRunner runner, bool hasState)
 Called before the network object is despawned More...
 
- Public Member Functions inherited from NetworkBehaviour
delegate int[] InterestGroupsCallback (Type type, NetworkBehaviour behaviour)
 
int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject. More...
 
void CopyStateFrom (NetworkBehaviour source)
 Copies entire state of passed in source NetworkBehaviour More...
 
override void FixedUpdateNetwork ()
 Fusion FixedUpdate timing callback. More...
 
virtual void CopyBackingFieldsToState (bool firstTime)
 
virtual void CopyStateToBackingFields ()
 
virtual void Spawned ()
 Post spawn callback. More...
 
bool GetInterpolationData (out InterpolationData data, bool? predicted=null)
 Get 'To' and 'From' states, and the Alpha (t) values needed for lerping. More...
 
bool GetInterpolationData (out InterpolationData data, out bool predicted)
 Get 'To' and 'From' states, and the Alpha (t) values needed for interpolation. More...
 
virtual bool IsInterpolationDataPredicted ()
 If the behaviour data should be interpolated between latest predicted states or between snapshots. More...
 
void OnChangeClearAll ()
 Clear all dynamic OnChange callbacks from this behaviour More...
 
bool OnChangeRemove (NetworkBehaviourCallbackReference reference)
 Removes a specific OnChange callback from this behaviour More...
 
NetworkBehaviourCallbackReference OnChangeAdd< T > (int wordOffset, int wordCount, ChangedDelegate< T > callback, OnChangedTargets targets=OnChangedTargets.All)
 Adds a OnChange callback to this behaviour which is bound to a specific word offset and word count More...
 
NetworkBehaviourCallbackReference OnChangeAdd< T > (string propertyName, ChangedDelegate< T > callback, OnChangedTargets targetses=OnChangedTargets.All)
 Adds a OnChange callback to this behaviour which is bound to a specific weaved property More...
 
T? GetInput< T > ()
 
bool GetInput< T > (out T input)
 Returns true if it a valid INetworkInput can be found for the current simulation tick (Typically this is used in FixedUpdateNetwork). More...
 
RawInterpolator GetInterpolator (string propertyName)
 Get a raw interpolator for a networked property. The returned RawInterpolator provides a way to calculate the "between-ticks" value of the named [Networked] property. More...
 
Interpolator< T > GetInterpolator< T > (string propertyName)
 Get an interpolator for a networked property. The returned Interpolator provides a way to calculate the "between-ticks" value of the named [Networked] property with the specified type T. The value is a linear interpolation between the "from" and the "to" ticks and is available via the Value property on the Interpolator. 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...
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent() More...
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren() More...
 

Public Attributes

float BroadRadius
 The radius of the broadphase bounding sphere for this Hitbox group. Used by HitboxManager to insert/update lag compensated NetworkObjects into its BVH (bounding volume hierarchy) data structure. Be sure this radius encompasses all children Hitbox components (including their full ranges of animation motion). We plan to offer an option to dynamically compute the bounding volume, but the performance trade of will still favor a hand-crafted radius. More...
 
Vector3 Offset
 Local-space offset of the broadphase bounding sphere from its transform position. More...
 
Color GizmosColor = Color.gray
 Color used when drawing gizmos for this hitbox. More...
 
Hitbox[] Hitboxes
 All Hitbox instances in hierarchy. Auto-filled at Spawned. More...
 
- Public Attributes inherited from NetworkBehaviour
int * Ptr
 Pointer to the allocated memory associated with this Object. More...
 
int ObjectIndex
 The index of this NetworkBehaviour, in the NetworkObject.NetworkedBehaviours array. More...
 
bool InvokeRpc
 
int offset
 Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data More...
 
- Public Attributes inherited from SimulationBehaviour
NetworkRunner Runner
 The NetworkRunner this component is associated with. More...
 
NetworkObject Object
 The NetworkObject this component is associated with. May be null if this GameObject does not have a NetworkObject. More...
 

Static Public Attributes

const Int32 MAX_HITBOXES = (sizeof(UInt32) * 8) - 1
 The max number of hitboxes allowed under the same root. More...
 

Protected Member Functions

virtual void DrawGizmos (Color color, ref Matrix4x4 localToWorldMatrix)
 

Properties

bool HitboxRootActive [get, set]
 Get or set the state of this HitboxRoot. For a hitbox to be hit by lag-compensated queries, both it and its HitboxRoot must be active. More...
 
HitboxManager Manager [get]
 Reference to associated hitbox manager (from which lag compensated queries can be performed). More...
 
- Properties inherited from NetworkBehaviour
InterpolationDataSources InterpolationDataSource [get, set]
 Get/Set the time frame this object is rendered in. More...
 
NetworkBehaviourId Id [get]
 The unique identifier for this network behaviour. More...
 
virtual ? int DynamicWordCount [get]
 Override this value for custom memory allocations. This is for advanced use cases only, and cannot be used if NetworkedAttribute is used in the derived class.
More...
 
virtual bool InvokeOnChangedForInitialNonZeroValues [get]
 Override this property to change whether initial non-zero values assigned to [Networked] properties invoke OnChanged callbacks. For clients the initial value comes from the simulation snapshot, not from what has been set locally in the inspector. 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...
 

Additional Inherited Members

- Public Types inherited from NetworkBehaviour
enum class  InterpolationDataSources
 Options for which time frame this object will render in. More...
 
- Static Public Member Functions inherited from NetworkBehaviour
static int NetworkSerialize (NetworkRunner runner, NetworkBehaviour obj, byte *data)
 
static int NetworkDeserialize (NetworkRunner runner, byte *data, ref NetworkBehaviour result)
 
static NetworkBehaviourId NetworkWrap (NetworkRunner runner, NetworkBehaviour obj)
 
static NetworkBehaviour NetworkUnwrap (NetworkRunner runner, NetworkBehaviourId wrapper)
 
static ref T MakeRef< T > ()
 
static ref T MakeRef< T > (T defaultValue)
 
static T * MakePtr< T > ()
 
static T * MakePtr< T > (T defaultValue)
 
static NetworkBehaviourUtils.ArrayInitializer< T > MakeInitializer< T > (T[] array)
 This is a special method that is meant to be used only for [Networked] properties inline initialization. More...
 
static NetworkBehaviourUtils.DictionaryInitializer< K, V > MakeInitializer< K, V > (Dictionary< K, V > dictionary)
 This is a special method that is meant to be used only for [Networked] properties inline initialization. More...
 
static implicit operator NetworkBehaviourId (NetworkBehaviour behaviour)
 Converts NetworkBehaviour to NetworkBehaviourId More...
 
- Static Public Member Functions inherited from Behaviour
static void DestroyBehaviour (Behaviour behaviour)
 Wrapper for Unity's GameObject.Destroy() More...
 

Detailed Description

Root Hitbox group container. Manages registering/unregistering hitboxes with the group, and defines the broadphase geometry for the group.

Broadphase is the initial rough query used by raycasts/overlaps/etc to find potential hit candidates, which are then used in the final narrowphase query.

Member Function Documentation

◆ Despawned()

override void Despawned ( NetworkRunner  runner,
bool  hasState 
)
virtual

Called before the network object is despawned

Parameters
hasStateIf the state of the behaviour is still accessible

Reimplemented from NetworkBehaviour.

◆ InitHitboxes()

void InitHitboxes ( )

Finds child Hitbox components, and adds them to the Hitboxes collection.

◆ IsHitboxActive()

bool IsHitboxActive ( Hitbox  hitbox)

Checks the state of a Hitbox instance under this root. Both the hitbox and its root must be active in order for it to be hit by lag-compensated queries.

Parameters
hitboxA hitbox instance under the hierarchy of this root.
Returns
True if the hitbox is part of this root and is active.
Exceptions
ArgumentOutOfRangeExceptionIf the Hitbox.HitboxIndex of the hitbox is outside the valid range.
AssertExceptionIn Debug configuration, if the hitbox is not part of this root.

◆ SetHitboxActive()

void SetHitboxActive ( Hitbox  hitbox,
bool  setActive 
)

Sets the state of a Hitbox instance under this root. Both the hitbox and its root must be active in order for it to be hit by lag-compensated queries.

Parameters
hitboxA hitbox instance under the hierarchy of this root.
setActiveIf the hitbox should be activated or deactivated.
Exceptions
ArgumentOutOfRangeExceptionIf the Hitbox.HitboxIndex of the hitbox is outside the valid range.
AssertExceptionIn Debug configuration, if the hitbox is not part of this root.

◆ SetMinBoundingRadius()

void SetMinBoundingRadius ( )

Sets BroadRadius to a rough value which encompasses all Hitboxes in their current positions.

Member Data Documentation

◆ BroadRadius

float BroadRadius

The radius of the broadphase bounding sphere for this Hitbox group. Used by HitboxManager to insert/update lag compensated NetworkObjects into its BVH (bounding volume hierarchy) data structure. Be sure this radius encompasses all children Hitbox components (including their full ranges of animation motion). We plan to offer an option to dynamically compute the bounding volume, but the performance trade of will still favor a hand-crafted radius.

Broadphase is the initial rough query used by raycasts/overlaps/etc to find potential hit candidates, which are then used in the final narrowphase query.

◆ GizmosColor

Color GizmosColor = Color.gray

Color used when drawing gizmos for this hitbox.

◆ Hitboxes

Hitbox [] Hitboxes

All Hitbox instances in hierarchy. Auto-filled at Spawned.

◆ MAX_HITBOXES

const Int32 MAX_HITBOXES = (sizeof(UInt32) * 8) - 1
static

The max number of hitboxes allowed under the same root.

◆ Offset

Vector3 Offset

Local-space offset of the broadphase bounding sphere from its transform position.

Adjust the BroadRadius and Offset until the sphere gizmo (shown in the Unity Scene window) encompasses all children Hitbox components (including their full ranges of animation motion).

Broadphase is the initial rough query used by raycasts/overlaps/etc to find potential hit candidates, which are then used in the final narrowphase query.

Property Documentation

◆ HitboxRootActive

bool HitboxRootActive
getset

Get or set the state of this HitboxRoot. For a hitbox to be hit by lag-compensated queries, both it and its HitboxRoot must be active.

◆ Manager

HitboxManager Manager
get

Reference to associated hitbox manager (from which lag compensated queries can be performed).