Photon Fusion 2.0.0

Public Member Functions | Public Attributes | Properties | List of all members
NetworkMecanimAnimator Class Reference

A component for synchronizing the Animator controller state from the State Authority to network proxies. Requires a Unity Animator component, and a NetworkObject component. NOTE: Animator Root Motion is not compatible with re-simulation and prediction. More...

Inherits NetworkBehaviour, and IAfterAllTicks.

Public Member Functions

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.
 
void SetTrigger (int triggerHash, bool passThroughOnInputAuthority=false)
 Queues a SetTrigger() call for the associated Animator on the State Authority. Call this instead of Animator.SetTrigger() for the State Authority to ensure that triggers are captured. On State Authority, this call will defer the SetTrigger() pass-through to the Animator until FixedUpdateNetwork() is called, where all queued triggers will be executed (this is to ensure tick agreement between server and clients).
 
void SetTrigger (string trigger, bool passThroughOnInputAuthority=false)
 Queues a SetTrigger() call for the associated Animator on the State Authority. Call this instead of Animator.SetTrigger() for the State Authority to ensure that triggers are captured. On State Authority, this call will defer the SetTrigger() pass-through to the Animator until FixedUpdateNetwork() is called, where all queued triggers will be executed (this is to ensure tick agreement between server and clients).
 
override void Spawned ()
 Post spawn callback.
 
- Public Member Functions inherited from NetworkBehaviour
virtual void CopyBackingFieldsToState (bool firstTime)
 Copies the backing fields to the state. This method is meant to be overridden in derived classes.
 
void CopyStateFrom (NetworkBehaviour source)
 Copies entire state of passed in source NetworkBehaviour
 
virtual void CopyStateToBackingFields ()
 Copies the state to the backing fields. This method is meant to be overridden in derived classes.
 
virtual void Despawned (NetworkRunner runner, bool hasState)
 Called before the network object is despawned.
 
override void FixedUpdateNetwork ()
 Fixed update callback for networked behaviours.
 
ArrayReader< T > GetArrayReader< T > (string property)
 Gets an ArrayReader for a network array of type T.
 
BehaviourReader< T > GetBehaviourReader< T > (string property)
 Gets a BehaviourReader for a network behaviour of type T.
 
ChangeDetector GetChangeDetector (ChangeDetector.Source source, bool copyInitial=true)
 Creates a ChangeDetector for this network behaviour.
 
DictionaryReader< K, V > GetDictionaryReader< K, V > (string property)
 Gets a DictionaryReader for a network dictionary with keys of type K and values of type V.
 
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).
 
LinkListReader< T > GetLinkListReader< T > (string property)
 Gets a LinkListReader for a network linked list of type T.
 
int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject.
 
PropertyReader< T > GetPropertyReader< T > (string property)
 Gets a PropertyReader for a property of type T in this network behaviour.
 
ref T ReinterpretState< T > (int offset=0)
 Allows read and write access to the internal state buffer.
 
void ReplicateTo (PlayerRef player, bool replicate)
 Controls if this network behaviours state is replicated to a player or not.
 
void ReplicateToAll (bool replicate)
 Sets the default replicated state for this behaviour, this by default is true so calling ReplicateToAll(true) does nothing if ReplicateToAll(false) hasn't been called before

 
void ResetState ()
 Resets the state of the object to the original state.
 
virtual void Spawned ()
 Post spawn callback.
 
bool TryGetSnapshotsBuffers (out NetworkBehaviourBuffer from, out NetworkBehaviourBuffer to, out float alpha)
 Tries to get the snapshot buffers for this network behaviour.
 
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 Spawned ()
 Method to be called when an object is spawned.
 
void Despawned (NetworkRunner runner, bool hasState)
 Called when a NetworkBehaviour is despawned.
 
void AfterAllTicks (bool resimulation, int tickCount)
 Called after the re-simulation loop (when applicable), and also after the forward simulation loop. Only called on Updates where re-simulation or forward ticks are processed.
 

Public Attributes

Animator Animator
 The Animator being synced. If unset, will attempt to find one on this GameObject.
 
RenderSource ApplyTiming = RenderSource.To
 The source of the State which is applied in Render.
 
- Public Attributes inherited from NetworkBehaviour
int offset
 Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data.
 

Properties

override? int DynamicWordCount [get]
 Gets the dynamic word count for the NetworkMecanimAnimator.
 
- Properties inherited from NetworkBehaviour
Tick ChangedTick [get]
 The tick the data on this networked behaviour changed.
 
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.

 
bool HasInputAuthority [get]
 Returns true if the Simulation.LocalPlayer of the associated NetworkRunner is the designated as Input Source for this network entity.
 
bool HasStateAuthority [get]
 Returns true if the associated NetworkRunner is the State Source for this network entity.
 
NetworkBehaviourId Id [get]
 The unique identifier for this network behaviour.
 
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.
 
NetworkBehaviourBuffer StateBuffer [get]
 Gets the state buffer associated with the network behaviour.
 
bool StateBufferIsValid [get]
 Gets a value indicating whether the state buffer is valid.
 
int int count WordInfo [get]
 
- 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.
 

Additional Inherited Members

- Static Public Member Functions inherited from NetworkBehaviour
static ArrayReader< T > GetArrayReader< T > (Type behaviourType, string property, IElementReaderWriter< T > readerWriter=null)
 Gets an ArrayReader for a network array of type T in a network behaviour of a specific type.
 
static BehaviourReader< T > GetBehaviourReader< T > (NetworkRunner runner, Type behaviourType, string property)
 Gets a BehaviourReader for a network behaviour of type T.
 
static BehaviourReader< TProperty > GetBehaviourReader< TBehaviour, TProperty > (NetworkRunner runner, string property)
 Gets a BehaviourReader for a network behaviour with a specific property of type TProperty.
 
static DictionaryReader< K, V > GetDictionaryReader< K, V > (Type behaviourType, string property, IElementReaderWriter< K > keyReaderWriter=null, IElementReaderWriter< V > valueReaderWriter=null)
 Gets a DictionaryReader for a network dictionary with keys of type K and values of type V in a network behaviour of a specific type.
 
static LinkListReader< T > GetLinkListReader< T > (Type behaviourType, string property, IElementReaderWriter< T > readerWriter=null)
 Gets a LinkListReader for a network linked list of type T in a network behaviour of a specific type.
 
static PropertyReader< T > GetPropertyReader< T > (Type behaviourType, string property)
 Gets a PropertyReader for a property of type T in a network behaviour of a specific type.
 
static PropertyReader< TProperty > GetPropertyReader< TBehaviour, TProperty > (string property)
 Gets a PropertyReader for a property of type TProperty in a network behaviour of type TBehaviour.
 
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.
 
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.
 
static T * MakePtr< T > ()
 Creates a pointer to a value of type T. This method is meant to be used only for [Networked] properties inline initialization.
 
static T * MakePtr< T > (T defaultValue)
 Creates a pointer to a value of type T, initializing it with the provided default value. This method is meant to be used only for [Networked] properties inline initialization.
 
static ref T MakeRef< T > ()
 Creates a reference to a value of type T. This method is meant to be used only for [Networked] properties inline initialization.
 
static ref T MakeRef< T > (T defaultValue)
 Creates a reference to a value of type T, initializing it with the provided default value. This method is meant to be used only for [Networked] properties inline initialization.
 
static int NetworkDeserialize (NetworkRunner runner, byte *data, ref NetworkBehaviour result)
 Deserializes a NetworkBehaviour from a byte array.
 
static int NetworkSerialize (NetworkBehaviour obj, byte *data)
 Serializes a NetworkBehaviour into a byte array.
 
static int NetworkSerialize (NetworkRunner runner, NetworkBehaviour obj, byte *data)
 Serializes a NetworkBehaviour into a byte array.
 
static NetworkBehaviour NetworkUnwrap (NetworkRunner runner, NetworkBehaviourId wrapper)
 Converts a NetworkBehaviourId to a NetworkBehaviour.
 
static NetworkBehaviourId NetworkWrap (NetworkRunner runner, NetworkBehaviour obj)
 Converts a NetworkBehaviour to a NetworkBehaviourId.
 
static implicit operator NetworkBehaviourId (NetworkBehaviour behaviour)
 Converts NetworkBehaviour to NetworkBehaviourId.
 
- Static Public Member Functions inherited from Behaviour
static void DestroyBehaviour (Behaviour behaviour)
 Wrapper for Unity's GameObject.Destroy()
 
- Protected Member Functions inherited from NetworkBehaviour
virtual bool ReplicateTo (PlayerRef player)
 Determines whether to replicate the network behaviour to the specified player. This method can be overridden in derived classes to implement custom replication logic.
 

Detailed Description

A component for synchronizing the Animator controller state from the State Authority to network proxies. Requires a Unity Animator component, and a NetworkObject component. NOTE: Animator Root Motion is not compatible with re-simulation and prediction.

Member Function Documentation

◆ 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.

◆ SetTrigger() [1/2]

void SetTrigger ( int  triggerHash,
bool  passThroughOnInputAuthority = false 
)

Queues a SetTrigger() call for the associated Animator on the State Authority. Call this instead of Animator.SetTrigger() for the State Authority to ensure that triggers are captured. On State Authority, this call will defer the SetTrigger() pass-through to the Animator until FixedUpdateNetwork() is called, where all queued triggers will be executed (this is to ensure tick agreement between server and clients).

Parameters
triggerHashTrigger hash to set
passThroughOnInputAuthorityWill call Animator.SetTrigger() immediately on the InputAuthority. If false, SetTrigger() will not be called on the Input Authority at all and Animator.SetTrigger() should be called explicitly as needed.

◆ SetTrigger() [2/2]

void SetTrigger ( string  trigger,
bool  passThroughOnInputAuthority = false 
)

Queues a SetTrigger() call for the associated Animator on the State Authority. Call this instead of Animator.SetTrigger() for the State Authority to ensure that triggers are captured. On State Authority, this call will defer the SetTrigger() pass-through to the Animator until FixedUpdateNetwork() is called, where all queued triggers will be executed (this is to ensure tick agreement between server and clients).

Parameters
triggerTrigger name to set
passThroughOnInputAuthorityWill call Animator.SetTrigger() immediately on the InputAuthority. If false, SetTrigger() will not be called on the Input Authority at all and Animator.SetTrigger() should be called explicitly as needed.

◆ Spawned()

override void Spawned ( )
virtual

Post spawn callback.

Reimplemented from NetworkBehaviour.

Property Documentation

◆ DynamicWordCount

override? int DynamicWordCount
get

Gets the dynamic word count for the NetworkMecanimAnimator.

The dynamic word count, which is the maximum of the current total words and the runtime counts, if the application is playing.

Exceptions
System.InvalidOperationExceptionThrown when this property is accessed outside of playing.