docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class NetworkTransform

    A component for syncing transforms. NetworkTransform will read the underlying transform and replicate it to clients. The replicated value will be automatically be interpolated (if active) and applied to the underlying GameObject's transform.

    Inheritance
    object
    Object
    Component
    Behaviour
    MonoBehaviour
    NetworkBehaviour
    NetworkTransform
    AnticipatedNetworkTransform
    ChildObjectComponent
    NetworkTransformOwnershipTests.TestClientNetworkTransform
    NetworkTransformTestComponent
    TransformInterpolationObject
    Inherited Members
    NetworkBehaviour.__rpc_func_table
    NetworkBehaviour.__rpc_name_table
    NetworkBehaviour.__rpc_exec_stage
    NetworkBehaviour.NetworkVariableFields
    NetworkBehaviour.__getTypeName()
    NetworkBehaviour.__beginSendServerRpc(uint, ServerRpcParams, RpcDelivery)
    NetworkBehaviour.__endSendServerRpc(ref FastBufferWriter, uint, ServerRpcParams, RpcDelivery)
    NetworkBehaviour.__beginSendClientRpc(uint, ClientRpcParams, RpcDelivery)
    NetworkBehaviour.__endSendClientRpc(ref FastBufferWriter, uint, ClientRpcParams, RpcDelivery)
    NetworkBehaviour.__beginSendRpc(uint, RpcParams, RpcAttribute.RpcAttributeParams, SendTo, RpcDelivery)
    NetworkBehaviour.__endSendRpc(ref FastBufferWriter, uint, RpcParams, RpcAttribute.RpcAttributeParams, SendTo, RpcDelivery)
    NetworkBehaviour.__createNativeList<T>()
    NetworkBehaviour.GetNetworkBehaviour(ushort)
    NetworkBehaviour.OnNetworkPreSpawn(ref NetworkManager)
    NetworkBehaviour.OnNetworkPostSpawn()
    NetworkBehaviour.OnNetworkSessionSynchronized()
    NetworkBehaviour.OnInSceneObjectsSpawned()
    NetworkBehaviour.__initializeVariables()
    NetworkBehaviour.__initializeRpcs()
    NetworkBehaviour.__registerRpc(uint, NetworkBehaviour.RpcReceiveHandler, string)
    NetworkBehaviour.__nameNetworkVariable(NetworkVariableBase, string)
    NetworkBehaviour.GetNetworkObject(ulong)
    NetworkBehaviour.OnReanticipate(double)
    NetworkBehaviour.NetworkManager
    NetworkBehaviour.RpcTarget
    NetworkBehaviour.IsLocalPlayer
    NetworkBehaviour.IsOwner
    NetworkBehaviour.IsServer
    NetworkBehaviour.ServerIsHost
    NetworkBehaviour.IsClient
    NetworkBehaviour.IsHost
    NetworkBehaviour.IsOwnedByServer
    NetworkBehaviour.IsSpawned
    NetworkBehaviour.NetworkObject
    NetworkBehaviour.HasNetworkObject
    NetworkBehaviour.NetworkObjectId
    NetworkBehaviour.NetworkBehaviourId
    NetworkBehaviour.OwnerClientId
    NetworkBehaviour.m_TargetIdBeingSynchronized
    MonoBehaviour.IsInvoking()
    MonoBehaviour.CancelInvoke()
    MonoBehaviour.Invoke(string, float)
    MonoBehaviour.InvokeRepeating(string, float, float)
    MonoBehaviour.CancelInvoke(string)
    MonoBehaviour.IsInvoking(string)
    MonoBehaviour.StartCoroutine(string)
    MonoBehaviour.StartCoroutine(string, object)
    MonoBehaviour.StartCoroutine(IEnumerator)
    MonoBehaviour.StartCoroutine_Auto(IEnumerator)
    MonoBehaviour.StopCoroutine(IEnumerator)
    MonoBehaviour.StopCoroutine(Coroutine)
    MonoBehaviour.StopCoroutine(string)
    MonoBehaviour.StopAllCoroutines()
    MonoBehaviour.print(object)
    MonoBehaviour.useGUILayout
    MonoBehaviour.runInEditMode
    Behaviour.enabled
    Behaviour.isActiveAndEnabled
    Component.GetComponent(Type)
    Component.GetComponent<T>()
    Component.TryGetComponent(Type, out Component)
    Component.TryGetComponent<T>(out T)
    Component.GetComponent(string)
    Component.GetComponentInChildren(Type, bool)
    Component.GetComponentInChildren(Type)
    Component.GetComponentInChildren<T>(bool)
    Component.GetComponentInChildren<T>()
    Component.GetComponentsInChildren(Type, bool)
    Component.GetComponentsInChildren(Type)
    Component.GetComponentsInChildren<T>(bool)
    Component.GetComponentsInChildren<T>(bool, List<T>)
    Component.GetComponentsInChildren<T>()
    Component.GetComponentsInChildren<T>(List<T>)
    Component.GetComponentInParent(Type, bool)
    Component.GetComponentInParent(Type)
    Component.GetComponentInParent<T>(bool)
    Component.GetComponentInParent<T>()
    Component.GetComponentsInParent(Type, bool)
    Component.GetComponentsInParent(Type)
    Component.GetComponentsInParent<T>(bool)
    Component.GetComponentsInParent<T>(bool, List<T>)
    Component.GetComponentsInParent<T>()
    Component.GetComponents(Type)
    Component.GetComponents(Type, List<Component>)
    Component.GetComponents<T>(List<T>)
    Component.GetComponents<T>()
    Component.CompareTag(string)
    Component.SendMessageUpwards(string, object, SendMessageOptions)
    Component.SendMessageUpwards(string, object)
    Component.SendMessageUpwards(string)
    Component.SendMessageUpwards(string, SendMessageOptions)
    Component.SendMessage(string, object)
    Component.SendMessage(string)
    Component.SendMessage(string, object, SendMessageOptions)
    Component.SendMessage(string, SendMessageOptions)
    Component.BroadcastMessage(string, object, SendMessageOptions)
    Component.BroadcastMessage(string, object)
    Component.BroadcastMessage(string)
    Component.BroadcastMessage(string, SendMessageOptions)
    Component.transform
    Component.gameObject
    Component.tag
    Object.GetInstanceID()
    Object.GetHashCode()
    Object.Equals(object)
    Object.Instantiate(Object, Vector3, Quaternion)
    Object.Instantiate(Object, Vector3, Quaternion, Transform)
    Object.Instantiate(Object)
    Object.Instantiate(Object, Transform)
    Object.Instantiate(Object, Transform, bool)
    Object.Instantiate<T>(T)
    Object.Instantiate<T>(T, Vector3, Quaternion)
    Object.Instantiate<T>(T, Vector3, Quaternion, Transform)
    Object.Instantiate<T>(T, Transform)
    Object.Instantiate<T>(T, Transform, bool)
    Object.Destroy(Object, float)
    Object.Destroy(Object)
    Object.DestroyImmediate(Object, bool)
    Object.DestroyImmediate(Object)
    Object.FindObjectsOfType(Type)
    Object.FindObjectsOfType(Type, bool)
    Object.FindObjectsByType(Type, FindObjectsSortMode)
    Object.FindObjectsByType(Type, FindObjectsInactive, FindObjectsSortMode)
    Object.DontDestroyOnLoad(Object)
    Object.DestroyObject(Object, float)
    Object.DestroyObject(Object)
    Object.FindSceneObjectsOfType(Type)
    Object.FindObjectsOfTypeIncludingAssets(Type)
    Object.FindObjectsOfType<T>()
    Object.FindObjectsByType<T>(FindObjectsSortMode)
    Object.FindObjectsOfType<T>(bool)
    Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)
    Object.FindObjectOfType<T>()
    Object.FindObjectOfType<T>(bool)
    Object.FindFirstObjectByType<T>()
    Object.FindAnyObjectByType<T>()
    Object.FindFirstObjectByType<T>(FindObjectsInactive)
    Object.FindAnyObjectByType<T>(FindObjectsInactive)
    Object.FindObjectsOfTypeAll(Type)
    Object.FindObjectOfType(Type)
    Object.FindFirstObjectByType(Type)
    Object.FindAnyObjectByType(Type)
    Object.FindObjectOfType(Type, bool)
    Object.FindFirstObjectByType(Type, FindObjectsInactive)
    Object.FindAnyObjectByType(Type, FindObjectsInactive)
    Object.ToString()
    Object.name
    Object.hideFlags
    object.Equals(object, object)
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    Namespace: Unity.Netcode.Components
    Assembly: Unity.Netcode.Components.dll
    Syntax
    [DisallowMultipleComponent]
    [AddComponentMenu("Netcode/Network Transform")]
    [DefaultExecutionOrder(100000)]
    public class NetworkTransform : NetworkBehaviour

    Fields

    InLocalSpace

    Sets whether the transform should be treated as local (true) or world (false) space.

    Declaration
    [Tooltip("Sets whether this transform should sync in local space or in world space")]
    public bool InLocalSpace
    Field Value
    Type Description
    bool
    Remarks

    This is synchronized by authority. During runtime, this should only be changed by the authoritative side. Non-authoritative instances will be overridden by the next authoritative state update.

    Interpolate

    When enabled (default) interpolation is applied. When disabled interpolation is disabled.

    Declaration
    public bool Interpolate
    Field Value
    Type Description
    bool
    Remarks

    This is synchronized by authority and changes to interpolation during runtime forces a teleport/full update. During runtime, this should only be changed by the authoritative side. Non-authoritative instances will be overridden by the next authoritative state update.

    OnClientRequestChange

    The handler that gets invoked when server receives a change from a client. This handler would be useful for server to modify pos/rot/scale before applying client's request.

    Declaration
    public NetworkTransform.OnClientRequestChangeDelegate OnClientRequestChange
    Field Value
    Type Description
    NetworkTransform.OnClientRequestChangeDelegate

    PositionThreshold

    The position threshold value that triggers a delta state update by the authoritative instance.

    Declaration
    public float PositionThreshold
    Field Value
    Type Description
    float
    Remarks

    Note: setting this to zero will update position every network tick whether it changed or not.

    PositionThresholdDefault

    The default position change threshold value. Any changes above this threshold will be replicated.

    Declaration
    public const float PositionThresholdDefault = 0.001
    Field Value
    Type Description
    float

    RotAngleThreshold

    The rotation threshold value that triggers a delta state update by the authoritative instance.

    Declaration
    [Range(1E-05, 360)]
    public float RotAngleThreshold
    Field Value
    Type Description
    float
    Remarks

    Minimum Value: 0.00001 Maximum Value: 360.0

    RotAngleThresholdDefault

    The default rotation angle change threshold value. Any changes above this threshold will be replicated.

    Declaration
    public const float RotAngleThresholdDefault = 0.01
    Field Value
    Type Description
    float

    ScaleThreshold

    The scale threshold value that triggers a delta state update by the authoritative instance.

    Declaration
    public float ScaleThreshold
    Field Value
    Type Description
    float
    Remarks

    Note: setting this to zero will update position every network tick whether it changed or not.

    ScaleThresholdDefault

    The default scale change threshold value. Any changes above this threshold will be replicated.

    Declaration
    public const float ScaleThresholdDefault = 0.01
    Field Value
    Type Description
    float

    SlerpPosition

    When true and interpolation is enabled, this will Slerp to the target position.

    Declaration
    [Tooltip("When enabled the position interpolator will Slerp towards its current target position.")]
    public bool SlerpPosition
    Field Value
    Type Description
    bool
    Remarks

    This is synchronized by authority and only applies to position interpolation. During runtime, this should only be changed by the authoritative side. Non-authoritative instances will be overridden by the next authoritative state update.

    SyncPositionX

    When enabled (default), the x component of position will be synchronized by authority.

    Declaration
    public bool SyncPositionX
    Field Value
    Type Description
    bool
    Remarks

    Changes to this on non-authoritative instances has no effect.

    SyncPositionY

    When enabled (default), the y component of position will be synchronized by authority.

    Declaration
    public bool SyncPositionY
    Field Value
    Type Description
    bool
    Remarks

    Changes to this on non-authoritative instances has no effect.

    SyncPositionZ

    When enabled (default), the z component of position will be synchronized by authority.

    Declaration
    public bool SyncPositionZ
    Field Value
    Type Description
    bool
    Remarks

    Changes to this on non-authoritative instances has no effect.

    SyncRotAngleX

    When enabled (default), the x component of rotation will be synchronized by authority.

    Declaration
    public bool SyncRotAngleX
    Field Value
    Type Description
    bool
    Remarks

    When UseQuaternionSynchronization is enabled this does not apply. Changes to this on non-authoritative instances has no effect.

    SyncRotAngleY

    When enabled (default), the y component of rotation will be synchronized by authority.

    Declaration
    public bool SyncRotAngleY
    Field Value
    Type Description
    bool
    Remarks

    When UseQuaternionSynchronization is enabled this does not apply. Changes to this on non-authoritative instances has no effect.

    SyncRotAngleZ

    When enabled (default), the z component of rotation will be synchronized by authority.

    Declaration
    public bool SyncRotAngleZ
    Field Value
    Type Description
    bool
    Remarks

    When UseQuaternionSynchronization is enabled this does not apply. Changes to this on non-authoritative instances has no effect.

    SyncScaleX

    When enabled (default), the x component of scale will be synchronized by authority.

    Declaration
    public bool SyncScaleX
    Field Value
    Type Description
    bool
    Remarks

    Changes to this on non-authoritative instances has no effect.

    SyncScaleY

    When enabled (default), the y component of scale will be synchronized by authority.

    Declaration
    public bool SyncScaleY
    Field Value
    Type Description
    bool
    Remarks

    Changes to this on non-authoritative instances has no effect.

    SyncScaleZ

    When enabled (default), the z component of scale will be synchronized by authority.

    Declaration
    public bool SyncScaleZ
    Field Value
    Type Description
    bool
    Remarks

    Changes to this on non-authoritative instances has no effect.

    UseHalfFloatPrecision

    Enable this to use half float precision for position, rotation, and scale. When enabled, delta position synchronization is used.

    Declaration
    [Tooltip("When enabled, this will use half float precision values for position (uses delta position updating), rotation (except when Quaternion compression is enabled), and scale.")]
    public bool UseHalfFloatPrecision
    Field Value
    Type Description
    bool
    Remarks

    This is synchronized by authority. During runtime, this should only be changed by the authoritative side. Non-authoritative instances will be overridden by the next authoritative state update.

    UseQuaternionCompression

    Enabled this on the authority side for quaternion compression

    Declaration
    [Tooltip("When enabled, this uses a smallest three implementation that reduces full Quaternion updates down to the size of an unsigned integer (ignores half float precision settings).")]
    public bool UseQuaternionCompression
    Field Value
    Type Description
    bool
    Remarks

    This has a lower precision than half float precision. Recommended only for low precision scenarios. UseHalfFloatPrecision provides better precision at roughly half the cost of a full quaternion update. This is synchronized by authority. During runtime, this should only be changed by the authoritative side. Non-authoritative instances will be overridden by the next authoritative state update.

    UseQuaternionSynchronization

    Enable this on the authority side for quaternion synchronization

    Declaration
    [Tooltip("When enabled, this will synchronize the full Quaternion (i.e. all Euler rotation axis are updated if one axis has a delta)")]
    public bool UseQuaternionSynchronization
    Field Value
    Type Description
    bool
    Remarks

    This is synchronized by authority. During runtime, this should only be changed by the authoritative side. Non-authoritative instances will be overridden by the next authoritative state update.

    UseUnreliableDeltas

    Enabled by default. When set (enabled by default), NetworkTransform will send common state updates using unreliable network delivery to provide a higher tolerance to poor network conditions (especially packet loss). When disabled, all state updates are sent using a reliable fragmented sequenced network delivery.

    Declaration
    [Tooltip("When set, NetworkTransform will send common state updates using unreliable network delivery to provide a higher tolerance to poor network conditions (especially packet loss). When disabled, all state updates are sent using reliable fragmented sequenced network delivery.")]
    public bool UseUnreliableDeltas
    Field Value
    Type Description
    bool
    Remarks

    The following more critical state updates are still sent as reliable fragmented sequenced:

    • The initial synchronization state update
    • The teleporting state update.
    • When using half float precision and the NetworkDeltaPosition delta exceeds the maximum delta forcing the axis in question to be collapsed into the core base position, this state update will be sent as reliable fragmented sequenced.

    In order to preserve a continual consistency of axial values when unreliable delta messaging is enabled (due to the possibility of dropping packets), NetworkTransform instances will send 1 axial frame synchronization update per second (only for the axis marked to synchronize are sent as reliable fragmented sequenced) as long as a delta state update had been previously sent. When a NetworkObject is at rest, axial frame synchronization updates are not sent.

    m_AddLogEntry

    Declaration
    protected NetworkTransform.AddLogEntryHandler m_AddLogEntry
    Field Value
    Type Description
    NetworkTransform.AddLogEntryHandler

    m_CachedIsServer

    Internally used by NetworkTransform to keep track of whether this NetworkBehaviour derived class instance was instantiated on the server side or not.

    Declaration
    protected bool m_CachedIsServer
    Field Value
    Type Description
    bool

    m_CachedNetworkManager

    Internally used by NetworkTransform to keep track of the NetworkManager instance assigned to this this NetworkBehaviour derived class instance.

    Declaration
    protected NetworkManager m_CachedNetworkManager
    Field Value
    Type Description
    NetworkManager

    Properties

    CanCommitToTransform

    Used to determine who can write to this transform. Server only for this transform. Changing this value alone in a child implementation will not allow you to create a NetworkTransform which can be written to by clients. See the ClientNetworkTransform Sample in the package samples for how to implement a NetworkTransform with client write support. If using different values, please use RPCs to write to the server. Netcode doesn't support client side network variable writing

    Declaration
    public bool CanCommitToTransform { get; protected set; }
    Property Value
    Type Description
    bool

    Methods

    ApplyAuthoritativeState()

    Applies the authoritative state to the transform

    Declaration
    protected void ApplyAuthoritativeState()

    Awake()

    Create interpolators when first instantiated to avoid memory allocations if the associated NetworkObject persists (i.e. despawned but not destroyed or pools)

    Declaration
    protected virtual void Awake()

    GetHalfPositionState()

    Declaration
    protected NetworkDeltaPosition GetHalfPositionState()
    Returns
    Type Description
    NetworkDeltaPosition

    GetScale(bool)

    Helper method that returns the scale of the transform.

    Declaration
    public Vector3 GetScale(bool getCurrentState = false)
    Parameters
    Type Name Description
    bool getCurrentState

    Authority always returns the space relative transform scale (whether true or false). Non-authority: When false (default): returns the space relative transform scale When true: returns the authority scale from the most recent state update.

    Returns
    Type Description
    Vector3

    Vector3

    Remarks

    When invoked on the non-authority side: If getCurrentState is true then it will return the most current authority scale from the most recent state update. This can be useful if interpolation is enabled and you need to determine the final target scale. When invoked on the authority side: It will always return the space relative scale.

    GetSpaceRelativePosition(bool)

    Helper method that returns the space relative position of the transform.

    Declaration
    public Vector3 GetSpaceRelativePosition(bool getCurrentState = false)
    Parameters
    Type Name Description
    bool getCurrentState

    Authority always returns the space relative transform position (whether true or false). Non-authority: When false (default): returns the space relative transform position When true: returns the authority position from the most recent state update.

    Returns
    Type Description
    Vector3

    Vector3

    Remarks

    If InLocalSpace is true then it returns the transform.localPosition If InLocalSpace is false then it returns the transform.position When invoked on the non-authority side: If getCurrentState is true then it will return the most current authority position from the most recent state update. This can be useful if interpolation is enabled and you need to determine the final target position. When invoked on the authority side: It will always return the space relative position.

    GetSpaceRelativeRotation(bool)

    Helper method that returns the space relative rotation of the transform.

    Declaration
    public Quaternion GetSpaceRelativeRotation(bool getCurrentState = false)
    Parameters
    Type Name Description
    bool getCurrentState

    Authority always returns the space relative transform rotation (whether true or false). Non-authority: When false (default): returns the space relative transform rotation When true: returns the authority rotation from the most recent state update.

    Returns
    Type Description
    Quaternion

    Quaternion

    Remarks

    If InLocalSpace is true then it returns the transform.localRotation If InLocalSpace is false then it returns the transform.rotation When invoked on the non-authority side: If getCurrentState is true then it will return the most current authority rotation from the most recent state update. This can be useful if interpolation is enabled and you need to determine the final target rotation. When invoked on the authority side: It will always return the space relative rotation.

    GetStateId(ref NetworkTransformState)

    Declaration
    protected int GetStateId(ref NetworkTransform.NetworkTransformState state)
    Parameters
    Type Name Description
    NetworkTransform.NetworkTransformState state
    Returns
    Type Description
    int

    Initialize()

    Initializes NetworkTransform when spawned and ownership changes.

    Declaration
    protected void Initialize()

    IsServerAuthoritative()

    Method to determine if this NetworkTransform instance is owner or server authoritative.

    Declaration
    public bool IsServerAuthoritative()
    Returns
    Type Description
    bool

    true or false

    Remarks

    Used by NetworkRigidbody to determines if this is server or owner authoritative.

    OnAuthorityPushTransformState(ref NetworkTransformState)

    Invoked just prior to being pushed to non-authority instances.

    Declaration
    protected virtual void OnAuthorityPushTransformState(ref NetworkTransform.NetworkTransformState networkTransformState)
    Parameters
    Type Name Description
    NetworkTransform.NetworkTransformState networkTransformState

    the state being pushed

    Remarks

    This is useful to know the exact position, rotation, or scale values sent to non-authoritative instances. This is only invoked on the authoritative instance.

    OnBeforeUpdateTransformState()

    Declaration
    protected virtual void OnBeforeUpdateTransformState()

    OnDestroy()

    Declaration
    public override void OnDestroy()
    Overrides
    NetworkBehaviour.OnDestroy()

    OnGainedOwnership()

    Declaration
    public override void OnGainedOwnership()
    Overrides
    NetworkBehaviour.OnGainedOwnership()

    OnInitialize(ref NetworkTransformState)

    Invoked when first spawned and when ownership changes.

    Declaration
    protected virtual void OnInitialize(ref NetworkTransform.NetworkTransformState replicatedState)
    Parameters
    Type Name Description
    NetworkTransform.NetworkTransformState replicatedState

    the current NetworkTransform.NetworkTransformState after initializing

    OnInitialize(ref NetworkVariable<NetworkTransformState>)

    This method is only invoked by the owner Use: OnInitialize(ref NetworkTransformState replicatedState) to be notified on all instances

    Declaration
    protected virtual void OnInitialize(ref NetworkVariable<NetworkTransform.NetworkTransformState> replicatedState)
    Parameters
    Type Name Description
    NetworkVariable<NetworkTransform.NetworkTransformState> replicatedState

    OnIsServerAuthoritative()

    Override this method and return false to switch to owner authoritative mode

    Declaration
    protected virtual bool OnIsServerAuthoritative()
    Returns
    Type Description
    bool

    (true or false) where when false it runs as owner-client authoritative

    OnLostOwnership()

    Declaration
    public override void OnLostOwnership()
    Overrides
    NetworkBehaviour.OnLostOwnership()

    OnNetworkDespawn()

    Declaration
    public override void OnNetworkDespawn()
    Overrides
    NetworkBehaviour.OnNetworkDespawn()

    OnNetworkObjectParentChanged(NetworkObject)

    Declaration
    public override void OnNetworkObjectParentChanged(NetworkObject parentNetworkObject)
    Parameters
    Type Name Description
    NetworkObject parentNetworkObject
    Overrides
    NetworkBehaviour.OnNetworkObjectParentChanged(NetworkObject)
    Remarks

    When a parent changes, non-authoritative instances should:

    • Apply the resultant position, rotation, and scale from the parenting action.
    • Clear interpolators (even if not enabled on this frame)
    • Reset the interpolators to the position, rotation, and scale resultant values. This prevents interpolation visual anomalies and issues during initial synchronization

    OnNetworkSpawn()

    Declaration
    public override void OnNetworkSpawn()
    Overrides
    NetworkBehaviour.OnNetworkSpawn()

    OnNetworkTransformStateUpdated(ref NetworkTransformState, ref NetworkTransformState)

    Invoked on the non-authoritative side when the NetworkTransformState has been updated

    Declaration
    protected virtual void OnNetworkTransformStateUpdated(ref NetworkTransform.NetworkTransformState oldState, ref NetworkTransform.NetworkTransformState newState)
    Parameters
    Type Name Description
    NetworkTransform.NetworkTransformState oldState

    the previous NetworkTransform.NetworkTransformState

    NetworkTransform.NetworkTransformState newState

    the new NetworkTransform.NetworkTransformState

    OnOwnershipChanged(ulong, ulong)

    Declaration
    protected override void OnOwnershipChanged(ulong previous, ulong current)
    Parameters
    Type Name Description
    ulong previous
    ulong current
    Overrides
    NetworkBehaviour.OnOwnershipChanged(ulong, ulong)

    OnSynchronize<T>(ref BufferSerializer<T>)

    This is invoked when a new client joins (server and client sides) Server Side: Serializes as if we were teleporting (everything is sent via NetworkTransformState) Client Side: Adds the interpolated state which applies the NetworkTransformState as well

    Declaration
    protected override void OnSynchronize<T>(ref BufferSerializer<T> serializer) where T : IReaderWriter
    Parameters
    Type Name Description
    BufferSerializer<T> serializer
    Type Parameters
    Name Description
    T
    Overrides
    Unity.Netcode.NetworkBehaviour.OnSynchronize<T>(ref Unity.Netcode.BufferSerializer<T>)
    Remarks

    If a derived class overrides this, then make sure to invoke this base method!

    OnTransformUpdated()

    Declaration
    protected virtual void OnTransformUpdated()

    SetMaxInterpolationBound(float)

    Will set the maximum interpolation boundary for the interpolators of this NetworkTransform instance. This value roughly translates to the maximum value of 't' in Lerp(Vector3, Vector3, float) and Lerp(Quaternion, Quaternion, float) for all transform elements being monitored by NetworkTransform (i.e. Position, Scale, and Rotation)

    Declaration
    public void SetMaxInterpolationBound(float maxInterpolationBound)
    Parameters
    Type Name Description
    float maxInterpolationBound

    Maximum time boundary that can be used in a frame when interpolating between two values

    SetState(Vector3?, Quaternion?, Vector3?, bool)

    Directly sets a state on the authoritative transform. Owner clients can directly set the state on a server authoritative transform This will override any changes made previously to the transform This isn't resistant to network jitter. Server side changes due to this method won't be interpolated. The parameters are broken up into pos / rot / scale on purpose so that the caller can perturb just the desired one(s)

    Declaration
    public void SetState(Vector3? posIn = null, Quaternion? rotIn = null, Vector3? scaleIn = null, bool teleportDisabled = true)
    Parameters
    Type Name Description
    Vector3? posIn
    Quaternion? rotIn
    Vector3? scaleIn

    new scale to scale to. Can be null

    bool teleportDisabled

    When true (the default) the NetworkObject will not be teleported and, if enabled, will interpolate. When false the NetworkObject will teleport/apply the parameters provided immediately.

    Exceptions
    Type Condition
    Exception

    Teleport(Vector3, Quaternion, Vector3)

    Teleport the transform to the given values without interpolating

    Declaration
    public void Teleport(Vector3 newPosition, Quaternion newRotation, Vector3 newScale)
    Parameters
    Type Name Description
    Vector3 newPosition
    Quaternion newRotation
    Vector3 newScale

    new scale to scale to.

    Exceptions
    Type Condition
    Exception

    TryCommitTransformToServer(Transform, double)

    This will try to send/commit the current transform delta states (if any)

    Declaration
    protected void TryCommitTransformToServer(Transform transformToCommit, double dirtyTime)
    Parameters
    Type Name Description
    Transform transformToCommit

    the transform to be committed

    double dirtyTime

    time it was marked dirty

    Remarks

    Only client owners or the server should invoke this method

    Update()

    Declaration
    protected virtual void Update()
    Remarks

    If you override this method, be sure that:

    • Non-authority always invokes this base class method.
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)