Photon Fusion 1.1.2

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

Replicates a Unity Transform's position and rotation states from the NetworkObject.StateAuthority to all other peers. Add this component to a GameObject to sync the position and rotation. A NetworkObject is required on this GameObject or a parent of this GameObject. More...

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

Inherited by NetworkTransform.

Public Member Functions

override void Spawned ()
 Overrides NetworkBehaviour.Spawned. If overriding this method in an inheritor, the base method should be called. More...
 
virtual void BeforeUpdate ()
 Implements IBeforeUpdate. If overriding this method in an inheritor, the base method should be called. More...
 
virtual void BeforeAllTicks (bool resimulation, int tickCount)
 Implements IBeforeAllTicks. If overriding this method in an inheritor, the base method should be called. To extend the functionality of copying data from the networked buffer to the engine, override and extend CopyFromBufferToEngine instead. More...
 
virtual void AfterAllTicks (bool resimulation, int tickCount)
 Implements IAfterAllTicks. If overriding this method in an inheritor, the base method should be called. To extend the functionality of copying data from the engine to the networked buffer, override and extend CopyFromEngineToBuffer instead. More...
 
virtual void RemotePrefabCreated ()
 Implements IRemotePrefabCreated. If overriding this method in an inheritor, the base method should be called. More...
 
virtual void BeforeCopyPreviousState ()
 Implements IBeforeCopyPreviousState. If overriding this method in an inheritor, the base method should be called. More...
 
override void CopyBackingFieldsToState (bool firstTime)
 Implements NetworkBehaviour.CopyBackingFieldsToState. If overriding this method in an inheritor, the base method should be called. More...
 
void AfterHostMigration ()
 Invoked after the Host Migration happens in order to setup non-networked data on NetworkBehaviors
 
Vector3 ReadPosition ()
 Reads from the position field on this object's networked data with the default Runner position read accuracy. More...
 
Vector3 ReadPosition (int *ptr)
 Reads from a position field on the networked data pointed by ptr with the default Runner position read accuracy. More...
 
Quaternion ReadRotation ()
 Reads from the rotation field on this object's networked data with the default Runner position read accuracy. More...
 
Quaternion ReadRotation (int *ptr)
 Reads from a rotation field on the networked data pointed by ptr with the default Runner position read accuracy. More...
 
void WritePosition (Vector3 position)
 Writes to a position field on this object's networked data with the default Runner position write accuracy. More...
 
void WritePosition (Vector3 position, int *ptr)
 Writes to a position field on the networked data pointed by ptr with the default Runner position write accuracy. More...
 
void WriteRotation (Quaternion rotation)
 Writes to a rotation field on this object's networked data with the default Runner position write accuracy. More...
 
void WriteRotation (Quaternion rotation, int *ptr)
 Writes to a rotation field on the networked data pointed by ptr with the default Runner position write accuracy. 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 CopyStateToBackingFields ()
 
virtual void Despawned (NetworkRunner runner, bool hasState)
 Called before the network object is despawned 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...
 

Static Public Member Functions

static Vector3 ReadPosition (int *ptr, ReadAccuracy readAccuracy)
 Reads from a position field on the networked data pointed by ptr with the defined readAccuracy . More...
 
static Quaternion ReadRotation (int *ptr, ReadAccuracy readAccuracy)
 Reads from a rotation field on the networked data pointed by ptr with the defined readAccuracy . More...
 
static void WritePosition (Vector3 position, int *ptr, WriteAccuracy writeAccuracy)
 Writes to a position field on the networked data pointed by ptr with the defined writeAccuracy . More...
 
static void WriteRotation (Quaternion rotation, int *ptr, WriteAccuracy writeAccuracy)
 Writes to a rotation field on the networked data pointed by ptr with the defined writeAccuracy . 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...
 

Protected Member Functions

virtual void Awake ()
 Implements Unity's Awake event function. If overriding this method in an inheritor, the base method should be called. More...
 
virtual void OnEnable ()
 Implements Unity's OnEnable event function. If overriding this method in an inheritor, the base method should be called. More...
 
virtual void CopyFromBufferToEngine ()
 Sets the values retrieved from the networked data to the respective engine (Unity) fields. If overriding this method in an inheritor, the base method should be called. More...
 
virtual void CopyFromEngineToBuffer ()
 Sets the values retrieved from the engine (Unity) to the respective networked fields. If overriding this method in an inheritor, the base method should be called. More...
 
virtual Vector3 GetEnginePosition ()
 Gets the position value from the engine. By default, the world position is set to be the output. More...
 
virtual Quaternion GetEngineRotation ()
 Gets the rotation value from the engine. By default, the world rotation is set to be the output. More...
 
virtual void SetEnginePosition (Vector3 pos)
 Sets a position value to the engine. By default, the value is set to the transform's world position field. More...
 
virtual void SetEngineRotation (Quaternion rot)
 Sets a rotation value to the engine. By default, the value is set to the transform's world rotation field. More...
 

Static Protected Attributes

const int WORD_COUNT_NPR = OFFSET_ROTATION + WORD_COUNT_ROTATION
 Number of words used by a NetworkPositionRotation instance on its networked data, including all inherited fields. More...
 

Properties

Transform Transform [get]
 Cached GameObject.transform reference. More...
 
virtual int BaseWordCount [get]
 Number of words used by this class on the networked data buffer, including all inherited fields, to serve for reference to inheritors. More...
 
override int PositionWordOffset [get]
 Implements NetworkAreaOfInterestBehaviour by defining the word offset from the base pointer to the field that carries the position data used for Area of Interest management. More...
 
- 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
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...
 
- 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...
 

Detailed Description

Replicates a Unity Transform's position and rotation states from the NetworkObject.StateAuthority to all other peers. Add this component to a GameObject to sync the position and rotation. A NetworkObject is required on this GameObject or a parent of this GameObject.

This component does not interpolate visuals. In order to do that, use a NetworkTransform.

Member Function Documentation

◆ AfterAllTicks()

virtual void AfterAllTicks ( bool  resimulation,
int  tickCount 
)
virtual

Implements IAfterAllTicks. If overriding this method in an inheritor, the base method should be called. To extend the functionality of copying data from the engine to the networked buffer, override and extend CopyFromEngineToBuffer instead.

Implements IAfterAllTicks.

Reimplemented in NetworkRigidbodyBase.

◆ Awake()

virtual void Awake ( )
protectedvirtual

Implements Unity's Awake event function. If overriding this method in an inheritor, the base method should be called.

Reimplemented in NetworkRigidbody2D, and NetworkRigidbody.

◆ BeforeAllTicks()

virtual void BeforeAllTicks ( bool  resimulation,
int  tickCount 
)
virtual

Implements IBeforeAllTicks. If overriding this method in an inheritor, the base method should be called. To extend the functionality of copying data from the networked buffer to the engine, override and extend CopyFromBufferToEngine instead.

Implements IBeforeAllTicks.

Reimplemented in NetworkRigidbodyBase.

◆ BeforeCopyPreviousState()

virtual void BeforeCopyPreviousState ( )
virtual

Implements IBeforeCopyPreviousState. If overriding this method in an inheritor, the base method should be called.

Reimplemented in NetworkRigidbodyBase.

◆ BeforeUpdate()

virtual void BeforeUpdate ( )
virtual

Implements IBeforeUpdate. If overriding this method in an inheritor, the base method should be called.

Implements IBeforeUpdate.

Reimplemented in NetworkTransform.

◆ CopyBackingFieldsToState()

override void CopyBackingFieldsToState ( bool  firstTime)
virtual

Implements NetworkBehaviour.CopyBackingFieldsToState. If overriding this method in an inheritor, the base method should be called.

Reimplemented from NetworkBehaviour.

Reimplemented in NetworkRigidbodyBase.

◆ CopyFromBufferToEngine()

virtual void CopyFromBufferToEngine ( )
protectedvirtual

Sets the values retrieved from the networked data to the respective engine (Unity) fields. If overriding this method in an inheritor, the base method should be called.

Reimplemented in NetworkRigidbody2D, and NetworkRigidbody.

◆ CopyFromEngineToBuffer()

virtual void CopyFromEngineToBuffer ( )
protectedvirtual

Sets the values retrieved from the engine (Unity) to the respective networked fields. If overriding this method in an inheritor, the base method should be called.

Reimplemented in NetworkTransform, NetworkRigidbody2D, and NetworkRigidbody.

◆ GetEnginePosition()

virtual Vector3 GetEnginePosition ( )
protectedvirtual

Gets the position value from the engine. By default, the world position is set to be the output.

◆ GetEngineRotation()

virtual Quaternion GetEngineRotation ( )
protectedvirtual

Gets the rotation value from the engine. By default, the world rotation is set to be the output.

◆ OnEnable()

virtual void OnEnable ( )
protectedvirtual

Implements Unity's OnEnable event function. If overriding this method in an inheritor, the base method should be called.

◆ ReadPosition() [1/3]

Vector3 ReadPosition ( )

Reads from the position field on this object's networked data with the default Runner position read accuracy.

◆ ReadPosition() [2/3]

Vector3 ReadPosition ( int *  ptr)

Reads from a position field on the networked data pointed by ptr with the default Runner position read accuracy.

◆ ReadPosition() [3/3]

static Vector3 ReadPosition ( int *  ptr,
ReadAccuracy  readAccuracy 
)
static

Reads from a position field on the networked data pointed by ptr with the defined readAccuracy .

◆ ReadRotation() [1/3]

Quaternion ReadRotation ( )

Reads from the rotation field on this object's networked data with the default Runner position read accuracy.

◆ ReadRotation() [2/3]

Quaternion ReadRotation ( int *  ptr)

Reads from a rotation field on the networked data pointed by ptr with the default Runner position read accuracy.

◆ ReadRotation() [3/3]

static Quaternion ReadRotation ( int *  ptr,
ReadAccuracy  readAccuracy 
)
static

Reads from a rotation field on the networked data pointed by ptr with the defined readAccuracy .

◆ RemotePrefabCreated()

virtual void RemotePrefabCreated ( )
virtual

Implements IRemotePrefabCreated. If overriding this method in an inheritor, the base method should be called.

Reimplemented in NetworkRigidbodyBase.

◆ SetEnginePosition()

virtual void SetEnginePosition ( Vector3  pos)
protectedvirtual

Sets a position value to the engine. By default, the value is set to the transform's world position field.

◆ SetEngineRotation()

virtual void SetEngineRotation ( Quaternion  rot)
protectedvirtual

Sets a rotation value to the engine. By default, the value is set to the transform's world rotation field.

◆ Spawned()

override void Spawned ( )
virtual

Overrides NetworkBehaviour.Spawned. If overriding this method in an inheritor, the base method should be called.

Reimplemented from NetworkBehaviour.

Reimplemented in NetworkTransform, NetworkRigidbody2D, and NetworkRigidbody.

◆ WritePosition() [1/3]

void WritePosition ( Vector3  position)

Writes to a position field on this object's networked data with the default Runner position write accuracy.

◆ WritePosition() [2/3]

void WritePosition ( Vector3  position,
int *  ptr 
)

Writes to a position field on the networked data pointed by ptr with the default Runner position write accuracy.

◆ WritePosition() [3/3]

static void WritePosition ( Vector3  position,
int *  ptr,
WriteAccuracy  writeAccuracy 
)
static

Writes to a position field on the networked data pointed by ptr with the defined writeAccuracy .

◆ WriteRotation() [1/3]

void WriteRotation ( Quaternion  rotation)

Writes to a rotation field on this object's networked data with the default Runner position write accuracy.

◆ WriteRotation() [2/3]

void WriteRotation ( Quaternion  rotation,
int *  ptr 
)

Writes to a rotation field on the networked data pointed by ptr with the default Runner position write accuracy.

◆ WriteRotation() [3/3]

static void WriteRotation ( Quaternion  rotation,
int *  ptr,
WriteAccuracy  writeAccuracy 
)
static

Writes to a rotation field on the networked data pointed by ptr with the defined writeAccuracy .

Member Data Documentation

◆ WORD_COUNT_NPR

const int WORD_COUNT_NPR = OFFSET_ROTATION + WORD_COUNT_ROTATION
staticprotected

Number of words used by a NetworkPositionRotation instance on its networked data, including all inherited fields.

Property Documentation

◆ BaseWordCount

virtual int BaseWordCount
getprotected

Number of words used by this class on the networked data buffer, including all inherited fields, to serve for reference to inheritors.

◆ PositionWordOffset

override int PositionWordOffset
get

Implements NetworkAreaOfInterestBehaviour by defining the word offset from the base pointer to the field that carries the position data used for Area of Interest management.

◆ Transform

Transform Transform
get

Cached GameObject.transform reference.