Photon Fusion 2.0.4

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

Base class for Fusion network components, which are associated with a NetworkObject. More...

Inherits SimulationBehaviour, ISpawned, IDespawned, IElementReaderWriter< NetworkObject >, and IElementReaderWriter< NetworkBehaviour >.

Inherited by HitboxRoot, NetworkMecanimAnimator, and NetworkTRSP.

Classes

struct  ArrayReader
 Provides a reader for network arrays of type T. More...
 
struct  BehaviourReader
 Provides a reader for network behaviours of type T. More...
 
class  ChangeDetector
 Change detector for a NetworkBehaviour More...
 
struct  DictionaryReader
 Provides a reader for network dictionaries with keys of type K and values of type V. More...
 
struct  LinkListReader
 Provides a reader for network linked lists of type T. More...
 
struct  PropertyReader
 Provides a reader for properties of type T in a network behaviour. More...
 

Public Member Functions

virtual void CopyBackingFieldsToState (bool firstTime)
 Copies the backing fields to the state. This method is meant to be overridden in derived classes. More...
 
void CopyStateFrom (NetworkBehaviour source)
 Copies entire state of passed in source NetworkBehaviour More...
 
virtual void CopyStateToBackingFields ()
 Copies the state to the backing fields. This method is meant to be overridden in derived classes. More...
 
virtual void Despawned (NetworkRunner runner, bool hasState)
 Called before the network object is despawned More...
 
override void FixedUpdateNetwork ()
 Fixed update callback for networked behaviours. More...
 
ArrayReader< T > GetArrayReader< T > (string property)
 Gets an ArrayReader for a network array of type T. More...
 
BehaviourReader< T > GetBehaviourReader< T > (string property)
 Gets a BehaviourReader for a network behaviour of type T. More...
 
ChangeDetector GetChangeDetector (ChangeDetector.Source source, bool copyInitial=true)
 Creates a ChangeDetector for this network behaviour. More...
 
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. 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...
 
LinkListReader< T > GetLinkListReader< T > (string property)
 Gets a LinkListReader for a network linked list of type T. More...
 
int GetLocalAuthorityMask ()
 Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject. More...
 
PropertyReader< T > GetPropertyReader< T > (string property)
 Gets a PropertyReader for a property of type T in this network behaviour. More...
 
ref T ReinterpretState< T > (int offset=0)
 Allows read and write access to the internal state buffer More...
 
void ReplicateTo (PlayerRef player, bool replicate)
 Controls if this network behaviours state is replicated to a player or not More...
 
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
More...
 
void ResetState ()
 Resets the state of the object to the original state More...
 
virtual void Spawned ()
 Post spawn callback. More...
 
bool TryGetSnapshotsBuffers (out NetworkBehaviourBuffer from, out NetworkBehaviourBuffer to, out float alpha)
 Tries to get the snapshot buffers for this network behaviour. 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...
 
GetBehaviour< T > ()
 Wrapper for Unity's GameObject.GetComponentInChildren() More...
 
bool TryGetBehaviour< T > (out T behaviour)
 Wrapper for Unity's GameObject.TryGetComponent() More...
 
- Public Member Functions inherited from IElementReaderWriter< NetworkObject >
int GetElementHashCode (T element)
 Calculate the hash code of an element. More...
 
int GetElementWordCount ()
 Gets the word count of an element. More...
 
Read (byte *data, int index)
 Reads an element from the specified index in the byte array. More...
 
ref T ReadRef (byte *data, int index)
 Reads a reference to an element from the specified index in the byte array. More...
 
void Write (byte *data, int index, T element)
 Writes an element to the specified index in the byte array. More...
 
- Public Member Functions inherited from IElementReaderWriter< NetworkBehaviour >
int GetElementHashCode (T element)
 Calculate the hash code of an element. More...
 
int GetElementWordCount ()
 Gets the word count of an element. More...
 
Read (byte *data, int index)
 Reads an element from the specified index in the byte array. More...
 
ref T ReadRef (byte *data, int index)
 Reads a reference to an element from the specified index in the byte array. More...
 
void Write (byte *data, int index, T element)
 Writes an element to the specified index in the byte array. More...
 

Static Public Member Functions

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. More...
 
static BehaviourReader< T > GetBehaviourReader< T > (NetworkRunner runner, Type behaviourType, string property)
 Gets a BehaviourReader for a network behaviour of type T. More...
 
static BehaviourReader< TProperty > GetBehaviourReader< TBehaviour, TProperty > (NetworkRunner runner, string property)
 Gets a BehaviourReader for a network behaviour with a specific property of type TProperty. More...
 
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. More...
 
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. More...
 
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. More...
 
static PropertyReader< TProperty > GetPropertyReader< TBehaviour, TProperty > (string property)
 Gets a PropertyReader for a property of type TProperty in a network behaviour of type TBehaviour. 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 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 > ()
 Creates a pointer to a value of type T. This method is meant to be used only for [Networked] properties inline initialization. More...
 
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. More...
 
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. More...
 
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. More...
 
static int NetworkDeserialize (NetworkRunner runner, byte *data, ref NetworkBehaviour result)
 Deserializes a NetworkBehaviour from a byte array. More...
 
static int NetworkSerialize (NetworkRunner runner, NetworkBehaviour obj, byte *data)
 Serializes a NetworkBehaviour into a byte array. More...
 
static NetworkBehaviour NetworkUnwrap (NetworkRunner runner, NetworkBehaviourId wrapper)
 Converts a NetworkBehaviourId to a NetworkBehaviour. More...
 
static NetworkBehaviourId NetworkWrap (NetworkBehaviour obj)
 Converts a NetworkBehaviour to a NetworkBehaviourId. More...
 
static NetworkBehaviourId NetworkWrap (NetworkRunner runner, NetworkBehaviour obj)
 Converts a NetworkBehaviour to a NetworkBehaviourId. 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...
 

Public Attributes

int offset
 Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data More...
 

Protected Member Functions

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

Properties

Tick ChangedTick [get]
 The tick the data on this networked behaviour changed 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...
 
bool? HasInputAuthority [get]
 Returns true if the Simulation.LocalPlayer of the associated NetworkRunner is the designated as Input Source for this network entity. More...
 
bool? HasStateAuthority [get]
 Returns true if the associated NetworkRunner is the State Source for this network entity. More...
 
NetworkBehaviourIdId [get]
 The unique identifier for this network behaviour. More...
 
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...
 
NetworkBehaviourBuffer StateBuffer [get]
 Gets the state buffer associated with the network behaviour. More...
 
bool StateBufferIsValid [get]
 Gets a value indicating whether the state buffer is valid. More...
 
- Properties inherited from SimulationBehaviour
bool CanReceiveRenderCallback [get]
 Gets a value indicating whether this instance can receive render callbacks. More...
 
bool CanReceiveSimulationCallback [get]
 Gets a value indicating whether this instance can receive simulation callbacks. More...
 
NetworkObject Object [get]
 The NetworkObject this component is associated with. More...
 
NetworkRunner Runner [get]
 The NetworkRunner this component is associated with. More...
 

Detailed Description

Base class for Fusion network components, which are associated with a NetworkObject.

Derived from SimulationBehaviour, components derived from this class are associated with a NetworkRunner and Simulation. Components derived from this class are associated with a parent NetworkObject. and can use the NetworkedAttribute on properties to automate state synchronization, and can use the RpcAttribute on methods, to automate messaging.

Member Function Documentation

◆ CopyBackingFieldsToState()

virtual void CopyBackingFieldsToState ( bool  firstTime)
virtual

Copies the backing fields to the state. This method is meant to be overridden in derived classes.

Parameters
firstTimeIndicates whether this is the first time the method is called.

◆ CopyStateFrom()

void CopyStateFrom ( NetworkBehaviour  source)

Copies entire state of passed in source NetworkBehaviour

Parameters
sourceSource NetworkBehaviour to copy data from

◆ CopyStateToBackingFields()

virtual void CopyStateToBackingFields ( )
virtual

Copies the state to the backing fields. This method is meant to be overridden in derived classes.

◆ Despawned()

virtual void Despawned ( NetworkRunner  runner,
bool  hasState 
)
virtual

Called before the network object is despawned

Parameters
runnerThe runner that owns the object
hasStateIf the state of the behaviour is still accessible

Implements IDespawned.

Reimplemented in HitboxRoot.

◆ FixedUpdateNetwork()

override void FixedUpdateNetwork ( )
virtual

Fixed update callback for networked behaviours.

Reimplemented from SimulationBehaviour.

◆ GetArrayReader< T >() [1/2]

ArrayReader<T> GetArrayReader< T > ( string  property)

Gets an ArrayReader for a network array of type T.

Template Parameters
TThe type of elements in the network array.
Parameters
propertyThe name of the property to be read.
Returns
An ArrayReader for the network array of type T.

◆ GetArrayReader< T >() [2/2]

static ArrayReader<T> GetArrayReader< T > ( Type  behaviourType,
string  property,
IElementReaderWriter< T >  readerWriter = null 
)
static

Gets an ArrayReader for a network array of type T in a network behaviour of a specific type.

Template Parameters
TThe type of elements in the network array.
Parameters
behaviourTypeThe type of the network behaviour.
propertyThe name of the property to be read.
readerWriter
Returns
An ArrayReader for the network array of type T in the network behaviour of the specified type.

◆ GetBehaviourReader< T >() [1/2]

static BehaviourReader<T> GetBehaviourReader< T > ( NetworkRunner  runner,
Type  behaviourType,
string  property 
)
static

Gets a BehaviourReader for a network behaviour of type T.

Template Parameters
TThe type of the network behaviour.
Parameters
runnerThe NetworkRunner associated with the network behaviour.
behaviourTypeThe type of the behaviour to be read.
propertyThe name of the property to be read.
Returns
A BehaviourReader for the network behaviour of type T.
Type Constraints
T :NetworkBehaviour 

◆ GetBehaviourReader< T >() [2/2]

BehaviourReader<T> GetBehaviourReader< T > ( string  property)

Gets a BehaviourReader for a network behaviour of type T.

Template Parameters
TThe type of the network behaviour.
Parameters
propertyThe name of the property to be read.
Returns
A BehaviourReader for the network behaviour of type T.
Type Constraints
T :NetworkBehaviour 

◆ GetBehaviourReader< TBehaviour, TProperty >()

static BehaviourReader<TProperty> GetBehaviourReader< TBehaviour, TProperty > ( NetworkRunner  runner,
string  property 
)
static

Gets a BehaviourReader for a network behaviour with a specific property of type TProperty.

Template Parameters
TBehaviourThe type of the network behaviour.
TPropertyThe type of the property in the network behaviour.
Parameters
runnerThe NetworkRunner associated with the network behaviour.
propertyThe name of the property to be read.
Returns
A BehaviourReader for the network behaviour with the specific property of type TProperty.
Type Constraints
TBehaviour :NetworkBehaviour 
TProperty :NetworkBehaviour 

◆ GetChangeDetector()

ChangeDetector GetChangeDetector ( ChangeDetector.Source  source,
bool  copyInitial = true 
)

Creates a ChangeDetector for this network behaviour.

Parameters
sourceThe source of the change detector.
copyInitialIndicates whether to copy the initial state of the network behaviour.
Returns
A ChangeDetector for this network behaviour.

◆ GetDictionaryReader< K, V >() [1/2]

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.

Template Parameters
KThe type of keys in the network dictionary.
VThe type of values in the network dictionary.
Parameters
propertyThe name of the property to be read.
Returns
A DictionaryReader for the network dictionary with keys of type K and values of type V.

◆ GetDictionaryReader< K, V >() [2/2]

static DictionaryReader<K, V> GetDictionaryReader< K, V > ( Type  behaviourType,
string  property,
IElementReaderWriter< K >  keyReaderWriter = null,
IElementReaderWriter< V >  valueReaderWriter = null 
)
static

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.

Template Parameters
KThe type of keys in the network dictionary.
VThe type of values in the network dictionary.
Parameters
behaviourTypeThe type of the network behaviour.
propertyThe name of the property to be read.
keyReaderWriter
valueReaderWriter
Returns
A DictionaryReader for the network dictionary with keys of type K and values of type V in the network behaviour of the specified type.

◆ GetInput< T >() [1/2]

T? GetInput< T > ( )

Template Parameters
T
Type Constraints
T :unmanaged 
T :INetworkInput 

◆ GetInput< T >() [2/2]

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

The returned input struct originates from the NetworkObject.InputAuthority, and if valid contains the inputs supplied by that PlayerRef for the current simulation tick.

Type Constraints
T :unmanaged 
T :INetworkInput 

◆ GetLinkListReader< T >() [1/2]

LinkListReader<T> GetLinkListReader< T > ( string  property)

Gets a LinkListReader for a network linked list of type T.

Template Parameters
TThe type of elements in the network linked list.
Parameters
propertyThe name of the property to be read.
Returns
A LinkListReader for the network linked list of type T.

◆ GetLinkListReader< T >() [2/2]

static LinkListReader<T> GetLinkListReader< T > ( Type  behaviourType,
string  property,
IElementReaderWriter< T >  readerWriter = null 
)
static

Gets a LinkListReader for a network linked list of type T in a network behaviour of a specific type.

Template Parameters
TThe type of elements in the network linked list.
Parameters
behaviourTypeThe type of the network behaviour.
propertyThe name of the property to be read.
readerWriter
Returns
A LinkListReader for the network linked list of type T in the network behaviour of the specified type.

◆ GetLocalAuthorityMask()

int GetLocalAuthorityMask ( )

Gets a bitmask of AuthorityMasks flags, representing the current local authority over this NetworkObject.

◆ GetPropertyReader< T >() [1/2]

PropertyReader<T> GetPropertyReader< T > ( string  property)

Gets a PropertyReader for a property of type T in this network behaviour.

Template Parameters
TThe type of the property in the network behaviour. Must be unmanaged.
Parameters
propertyThe name of the property to be read.
Returns
A PropertyReader for the property of type T in this network behaviour.
Type Constraints
T :unmanaged 

◆ GetPropertyReader< T >() [2/2]

static PropertyReader<T> GetPropertyReader< T > ( Type  behaviourType,
string  property 
)
static

Gets a PropertyReader for a property of type T in a network behaviour of a specific type.

Template Parameters
TThe type of the property in the network behaviour. Must be unmanaged.
Parameters
behaviourTypeThe type of the network behaviour.
propertyThe name of the property to be read.
Returns
A PropertyReader for the property of type T in the network behaviour of the specified type.
Type Constraints
T :unmanaged 

◆ GetPropertyReader< TBehaviour, TProperty >()

static PropertyReader<TProperty> GetPropertyReader< TBehaviour, TProperty > ( string  property)
static

Gets a PropertyReader for a property of type TProperty in a network behaviour of type TBehaviour.

Template Parameters
TBehaviourThe type of the network behaviour.
TPropertyThe type of the property in the network behaviour. Must be unmanaged.
Parameters
propertyThe name of the property to be read.
Returns
A PropertyReader for the property of type TProperty in the network behaviour of type TBehaviour.
Type Constraints
TBehaviour :NetworkBehaviour 
TProperty :unmanaged 

◆ MakeInitializer< K, V >()

static NetworkBehaviourUtils.DictionaryInitializer<K, V> MakeInitializer< K, V > ( Dictionary< K, V >  dictionary)
static

This is a special method that is meant to be used only for [Networked] properties inline initialization.

◆ MakeInitializer< T >()

static NetworkBehaviourUtils.ArrayInitializer<T> MakeInitializer< T > ( T[]  array)
static

This is a special method that is meant to be used only for [Networked] properties inline initialization.

◆ MakePtr< T >() [1/2]

static T* MakePtr< T > ( )
static

Creates a pointer to a value of type T. This method is meant to be used only for [Networked] properties inline initialization.

Template Parameters
TThe type of the value. Must be unmanaged.
Returns
A pointer to a value of type T.
Exceptions
NotImplementedExceptionThrown because this method is meant to be used only for [Networked] properties inline initialization.
Type Constraints
T :unmanaged 

◆ MakePtr< T >() [2/2]

static T* MakePtr< T > ( defaultValue)
static

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.

Template Parameters
TThe type of the value. Must be unmanaged.
Parameters
defaultValueThe default value to initialize the value with.
Returns
A pointer to a value of type T.
Exceptions
NotImplementedExceptionThrown because this method is meant to be used only for [Networked] properties inline initialization.
Type Constraints
T :unmanaged 

◆ MakeRef< T >() [1/2]

static ref T MakeRef< T > ( )
static

Creates a reference to a value of type T. This method is meant to be used only for [Networked] properties inline initialization.

Template Parameters
TThe type of the value. Must be unmanaged.
Returns
A reference to a value of type T.
Exceptions
NotImplementedExceptionThrown because this method is meant to be used only for [Networked] properties inline initialization.
Type Constraints
T :unmanaged 

◆ MakeRef< T >() [2/2]

static ref T MakeRef< T > ( defaultValue)
static

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.

Template Parameters
TThe type of the value. Must be unmanaged.
Parameters
defaultValueThe default value to initialize the value with.
Returns
A reference to a value of type T.
Exceptions
NotImplementedExceptionThrown because this method is meant to be used only for [Networked] properties inline initialization.
Type Constraints
T :unmanaged 

◆ NetworkDeserialize()

static int NetworkDeserialize ( NetworkRunner  runner,
byte *  data,
ref NetworkBehaviour  result 
)
static

Deserializes a NetworkBehaviour from a byte array.

Parameters
runnerThe NetworkRunner associated with the NetworkBehaviour.
dataThe byte pointer to read the serialized data from.
resultThe NetworkBehaviour to store the deserialized data in.
Returns
The size of the deserialized data in bytes.

◆ NetworkSerialize()

static int NetworkSerialize ( NetworkRunner  runner,
NetworkBehaviour  obj,
byte *  data 
)
static

Serializes a NetworkBehaviour into a byte array.

Parameters
runner
objThe NetworkBehaviour to be serialized.
dataThe byte pointer to write the serialized data to.
Returns
The size of the serialized data in bytes.

◆ NetworkUnwrap()

static NetworkBehaviour NetworkUnwrap ( NetworkRunner  runner,
NetworkBehaviourId  wrapper 
)
static

Converts a NetworkBehaviourId to a NetworkBehaviour.

Parameters
runnerThe NetworkRunner associated with the NetworkBehaviour.
wrapperThe NetworkBehaviourId to be converted.
Returns
The NetworkBehaviour represented by the NetworkBehaviourId. If the NetworkBehaviourId is not valid or a NetworkBehaviour with the NetworkBehaviourId does not exist, returns null.

◆ NetworkWrap() [1/2]

static NetworkBehaviourId NetworkWrap ( NetworkBehaviour  obj)
static

Converts a NetworkBehaviour to a NetworkBehaviourId.

Parameters
objThe NetworkBehaviour to be converted.
Returns
A NetworkBehaviourId representing the NetworkBehaviour. If the NetworkBehaviour is null or its NetworkObject's Id is default, returns a default NetworkBehaviourId.

◆ NetworkWrap() [2/2]

static NetworkBehaviourId NetworkWrap ( NetworkRunner  runner,
NetworkBehaviour  obj 
)
static

Converts a NetworkBehaviour to a NetworkBehaviourId.

Parameters
runnerThe NetworkRunner associated with the NetworkBehaviour.
objThe NetworkBehaviour to be converted.
Returns
A NetworkBehaviourId representing the NetworkBehaviour. If the NetworkBehaviour is null or its NetworkObject's Id is default, returns a default NetworkBehaviourId.

◆ operator NetworkBehaviourId()

static implicit operator NetworkBehaviourId ( NetworkBehaviour  behaviour)
static

Converts NetworkBehaviour to NetworkBehaviourId

Parameters
behaviourNetworkBehaviour to convert
Returns
NetworkBehaviourId representing the NetworkBehaviour

◆ ReinterpretState< T >()

ref T ReinterpretState< T > ( int  offset = 0)

Allows read and write access to the internal state buffer

Parameters
offsetThe offset to generate a ref for, in integer words
Template Parameters
TThe type of the ref to generate
Returns
Reference to the location in memory defined by offset
Type Constraints
T :unmanaged 

◆ ReplicateTo() [1/2]

virtual bool ReplicateTo ( PlayerRef  player)
protectedvirtual

Determines whether to replicate the network behaviour to the specified player. This method can be overridden in derived classes to implement custom replication logic.

Parameters
playerThe player to potentially replicate the network behaviour to.
Returns
True if the network behaviour should be replicated to the player, false otherwise. The default implementation always returns true.

◆ ReplicateTo() [2/2]

void ReplicateTo ( PlayerRef  player,
bool  replicate 
)

Controls if this network behaviours state is replicated to a player or not

Parameters
playerThe player to change replication status for
replicatetrue = replicate, false = don't replicate

◆ ReplicateToAll()

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

Parameters
replicateThe default state of this behaviour

◆ ResetState()

void ResetState ( )

Resets the state of the object to the original state

◆ Spawned()

virtual void Spawned ( )
virtual

Post spawn callback.

Implements ISpawned.

Reimplemented in NetworkTransform, and NetworkMecanimAnimator.

◆ TryGetSnapshotsBuffers()

bool TryGetSnapshotsBuffers ( out NetworkBehaviourBuffer  from,
out NetworkBehaviourBuffer  to,
out float  alpha 
)

Tries to get the snapshot buffers for this network behaviour.

Parameters
fromThe buffer representing the state of the network behaviour at the start of the render frame.
toThe buffer representing the state of the network behaviour at the end of the render frame.
alphaThe interpolation factor between the start and end of the render frame.
Returns
True if the snapshot buffers are valid, false otherwise.

Member Data Documentation

◆ offset

int offset

Gives access to the offset (in 32 bit words) and count (in 32 bit words) of this behaviour backing data

Property Documentation

◆ ChangedTick

Tick ChangedTick
get

The tick the data on this networked behaviour changed

◆ DynamicWordCount

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.

◆ HasInputAuthority

bool? HasInputAuthority
get

Returns true if the Simulation.LocalPlayer of the associated NetworkRunner is the designated as Input Source for this network entity.

◆ HasStateAuthority

bool? HasStateAuthority
get

Returns true if the associated NetworkRunner is the State Source for this network entity.

◆ Id

The unique identifier for this network behaviour.

◆ IsProxy

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.

◆ StateBuffer

NetworkBehaviourBuffer StateBuffer
get

Gets the state buffer associated with the network behaviour.

◆ StateBufferIsValid

bool StateBufferIsValid
get

Gets a value indicating whether the state buffer is valid.