Photon Fusion 1.1.11

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

Replicates Unity parenting. To network parent changes, the new parent must either be null or have a NetworkTransformAnchor or class derived from that on the GameObject, and the GameObject being re-parented also requires a NetworkTransformAnchor based Component. A NetworkObject is required on this GameObject or a parent of this GameObject. More...

Inherits NetworkAreaOfInterestBehaviour, IBeforeAllTicks, IAfterAllTicks, IRemotePrefabCreated, and IBeforeCopyPreviousState.

Inherited by NetworkTransformObsolete.

Public Member Functions

virtual void AfterAllTicks (bool resimulation, int tickCount)
 Called after the resimulation loop (when applicable), and also after the forward simulation loop. Only called on Updates where resimulation or forward ticks are processed. More...
 
virtual void BeforeAllTicks (bool resimulation, int tickCount)
 Called before the resimulation loop (when applicable), and also before the forward simulation loop. Only called on Updates where resimulation or forward ticks are processed. More...
 
virtual void BeforeCopyPreviousState ()
 
override void CopyBackingFieldsToState (bool firstTime)
 
virtual void RemotePrefabCreated ()
 
override 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 NetworkBehaviour
void CopyStateFrom (NetworkBehaviour source)
 Copies entire state of passed in source NetworkBehaviour More...
 
virtual void CopyStateToBackingFields ()
 
virtual void Despawned (NetworkRunner runner, bool hasState)
 Called before the network object is despawned More...
 
override void FixedUpdateNetwork ()
 Fusion FixedUpdate timing callback. 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...
 
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...
 
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...
 
int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject. More...
 
delegate int[] InterestGroupsCallback (Type type, NetworkBehaviour behaviour)
 
virtual bool IsInterpolationDataPredicted ()
 If the behaviour data should be interpolated between latest predicted states or between snapshots. 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...
 
void OnChangeClearAll ()
 Clear all dynamic OnChange callbacks from this behaviour More...
 
bool OnChangeRemove (NetworkBehaviourCallbackReference reference)
 Removes a specific OnChange callback from this behaviour More...
 
virtual void Spawned ()
 Post spawn callback. 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...
 

Protected Member Functions

virtual void Awake ()
 
void Copy2BufferAnchorState (int offset=PARENT_OFFSET)
 
bool Copy2EngineAnchorState ()
 
virtual void OnEnable ()
 

Protected Attributes

Transform _interpolationTarget
 The Transform object used for interpolation. Should be a non-physics GameObject. Typically a child of this Rigidbody, or a separate object without colliders. The runner/simulation with State Authority will not interpolate if target is null or the same GameObject as the Rigidbody, as this will conflict with the PhysX simulation. More...
 
bool DetachInterpTarget
 EXPERIMENTAL: To improve interpolation of scaling, the interpolation target is detached from its NetworkObject. Only check this if you are syncing scaling. When re-parenting, this component's InterpolationTarget will re-parent to the parent's InterpolationTarget. More...
 
bool SyncParent = true
 Indicates if Transform.parent will be synced. Parent syncing requires the parent of this object either be null or have a NetworkTransformAnchor component. More...
 

Static Protected Attributes

const int ANCHOR_WORD_COUNT = POSITION_OFFSET + 3
 The total number of words used by NetworkTransformAnchor. Derived classes using allocated memory should start their Ptr offsets using this value. More...
 
const int PARENT_OFFSET = 0
 The Ptr offset for the memory position of the Parent info. The parenting info is 2 words (8 bytes). More...
 
const int TELE_PAR_OFFSET = PARENT_OFFSET + 2
 The Ptr offset for the secondary teleport parent information. This parent is used by the lerp TO target leading up to the teleport. More...
 

Properties

Transform InterpolationTarget [get, set]
 The Transform object used for interpolation. Should be a non-physics GameObject. Typically a child of this GameObject without colliders, or a separate GameObject without colliders. More...
 
override int PositionWordOffset [get]
 Gets the Ptr offset of the Position values in allocated memory. More...
 
Transform Transform [get]
 
- Properties inherited from NetworkAreaOfInterestBehaviour
abstract int PositionWordOffset [get]
 The int* offset for the Ptr, for the memory location of the position data. More...
 
- Properties inherited from NetworkBehaviour
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...
 
NetworkBehaviourId Id [get]
 The unique identifier for this network behaviour. More...
 
InterpolationDataSources InterpolationDataSource [get, set]
 Get/Set the time frame this object is rendered in. 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 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 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 T * MakePtr< T > ()
 
static T * MakePtr< T > (T defaultValue)
 
static ref T MakeRef< T > ()
 
static ref T MakeRef< T > (T defaultValue)
 
static int NetworkDeserialize (NetworkRunner runner, byte *data, ref NetworkBehaviour result)
 
static int NetworkSerialize (NetworkRunner runner, NetworkBehaviour obj, byte *data)
 
static NetworkBehaviour NetworkUnwrap (NetworkRunner runner, NetworkBehaviourId wrapper)
 
static NetworkBehaviourId NetworkWrap (NetworkRunner runner, NetworkBehaviour obj)
 
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...
 
- Public Attributes inherited from NetworkBehaviour
bool InvokeRpc
 
int ObjectIndex
 The index of this NetworkBehaviour, in the NetworkObject.NetworkedBehaviours array. More...
 
int offset
 Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data More...
 
int * Ptr
 Pointer to the allocated memory associated with this Object. 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...
 

Detailed Description

Replicates Unity parenting. To network parent changes, the new parent must either be null or have a NetworkTransformAnchor or class derived from that on the GameObject, and the GameObject being re-parented also requires a NetworkTransformAnchor based Component. A NetworkObject is required on this GameObject or a parent of this GameObject.

Member Function Documentation

◆ AfterAllTicks()

virtual void AfterAllTicks ( bool  resimulation,
int  tickCount 
)
virtual

Called after the resimulation loop (when applicable), and also after the forward simulation loop. Only called on Updates where resimulation or forward ticks are processed.

Parameters
resimulationTrue if this is being called during the resimulation loop. False if during the forward simulation loop.
tickCountHow many resimulation or forward ticks are going to be processed.

Implements IAfterAllTicks.

◆ BeforeAllTicks()

virtual void BeforeAllTicks ( bool  resimulation,
int  tickCount 
)
virtual

Called before the resimulation loop (when applicable), and also before the forward simulation loop. Only called on Updates where resimulation or forward ticks are processed.

Parameters
resimulationTrue if this is being called during the resimulation loop. False if during the forward simulation loop.
tickCountHow many resimulation or forward ticks are going to be processed.

Implements IBeforeAllTicks.

◆ Copy2EngineAnchorState()

bool Copy2EngineAnchorState ( )
protected

Returns
Returns true if the parent has changed.

◆ Render()

override void Render ( )
virtual

Post simulation frame rendering callback. Runs after all simulations have finished. Use in place of Unity's Update when Fusion is handling Physics.

Reimplemented from SimulationBehaviour.

Reimplemented in NetworkTransformObsolete.

Member Data Documentation

◆ _interpolationTarget

Transform _interpolationTarget
protected

The Transform object used for interpolation. Should be a non-physics GameObject. Typically a child of this Rigidbody, or a separate object without colliders. The runner/simulation with State Authority will not interpolate if target is null or the same GameObject as the Rigidbody, as this will conflict with the PhysX simulation.

◆ ANCHOR_WORD_COUNT

const int ANCHOR_WORD_COUNT = POSITION_OFFSET + 3
staticprotected

The total number of words used by NetworkTransformAnchor. Derived classes using allocated memory should start their Ptr offsets using this value.

◆ DetachInterpTarget

bool DetachInterpTarget
protected

EXPERIMENTAL: To improve interpolation of scaling, the interpolation target is detached from its NetworkObject. Only check this if you are syncing scaling. When re-parenting, this component's InterpolationTarget will re-parent to the parent's InterpolationTarget.

◆ PARENT_OFFSET

const int PARENT_OFFSET = 0
staticprotected

The Ptr offset for the memory position of the Parent info. The parenting info is 2 words (8 bytes).

◆ SyncParent

bool SyncParent = true
protected

Indicates if Transform.parent will be synced. Parent syncing requires the parent of this object either be null or have a NetworkTransformAnchor component.

◆ TELE_PAR_OFFSET

const int TELE_PAR_OFFSET = PARENT_OFFSET + 2
staticprotected

The Ptr offset for the secondary teleport parent information. This parent is used by the lerp TO target leading up to the teleport.

Property Documentation

◆ InterpolationTarget

Transform InterpolationTarget
getset

The Transform object used for interpolation. Should be a non-physics GameObject. Typically a child of this GameObject without colliders, or a separate GameObject without colliders.

◆ PositionWordOffset

override int PositionWordOffset
get

Gets the Ptr offset of the Position values in allocated memory.