Struct NetworkTransform.NetworkTransformState
Data structure used to synchronize the NetworkTransform
Implements
Inherited Members
Namespace: Unity.Netcode.Components
Assembly: Unity.Netcode.Runtime.dll
Syntax
public struct NetworkTransform.NetworkTransformState : INetworkSerializable
Properties
HasPositionChange
When set, at least one of the position axis values has changed.
Declaration
public bool HasPositionChange { get; }
Property Value
Type | Description |
---|---|
bool |
HasPositionX
When set, the X-Axis position value has changed
Declaration
public bool HasPositionX { get; }
Property Value
Type | Description |
---|---|
bool |
HasPositionY
When set, the Y-Axis position value has changed
Declaration
public bool HasPositionY { get; }
Property Value
Type | Description |
---|---|
bool |
HasPositionZ
When set, the Z-Axis position value has changed
Declaration
public bool HasPositionZ { get; }
Property Value
Type | Description |
---|---|
bool |
HasRotAngleChange
When set, at least one of the rotation axis values has changed.
Declaration
public bool HasRotAngleChange { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When quaternion synchronization is enabled all axis are always updated.
HasRotAngleX
When set, the Euler rotation X-Axis value has changed.
Declaration
public bool HasRotAngleX { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When quaternion synchronization is enabled all axis are always updated.
HasRotAngleY
When set, the Euler rotation Y-Axis value has changed.
Declaration
public bool HasRotAngleY { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When quaternion synchronization is enabled all axis are always updated.
HasRotAngleZ
When set, the Euler rotation Z-Axis value has changed.
Declaration
public bool HasRotAngleZ { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When quaternion synchronization is enabled all axis are always updated.
HasScaleChange
When set, at least one of the scale axis values has changed.
Declaration
public bool HasScaleChange { get; }
Property Value
Type | Description |
---|---|
bool |
HasScaleX
When set, the X-Axis scale value has changed.
Declaration
public bool HasScaleX { get; }
Property Value
Type | Description |
---|---|
bool |
HasScaleY
When set, the Y-Axis scale value has changed.
Declaration
public bool HasScaleY { get; }
Property Value
Type | Description |
---|---|
bool |
HasScaleZ
When set, the Z-Axis scale value has changed.
Declaration
public bool HasScaleZ { get; }
Property Value
Type | Description |
---|---|
bool |
InLocalSpace
When set, the NetworkTransform is operates in local space
Declaration
public bool InLocalSpace { get; }
Property Value
Type | Description |
---|---|
bool |
IsSynchronizing
When set, this indicates it is the first state being synchronized. Typically when the associate NetworkObject is spawned or a client is being synchronized after connecting to a network session in progress.
Declaration
public bool IsSynchronizing { get; }
Property Value
Type | Description |
---|---|
bool |
IsTeleportingNextFrame
When set, the current state will be treated as a teleport.
Declaration
public bool IsTeleportingNextFrame { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
When teleporting:
- Interpolation is reset.
- If using half precision, full precision values are used.
- All axis marked to be synchronized will be updated.
LastSerializedSize
The last byte size of the NetworkTransform.NetworkTransformState updated.
Declaration
public readonly int LastSerializedSize { get; }
Property Value
Type | Description |
---|---|
int |
QuaternionCompression
When set Quaternions will be compressed down to 4 bytes using a smallest three implementation.
Declaration
public bool QuaternionCompression { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
This only will be applied when QuaternionSync is enabled. Half float precision provides a higher precision than quaternion compression but at the cost of 4 additional bytes per update.
- Quaternion Compression: 4 bytes per delta update
- Half float precision: 8 bytes per delta update
QuaternionSync
When enabled, this NetworkTransform instance uses Quaternion synchronization.
Declaration
public bool QuaternionSync { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Use quaternion synchronization if you are nesting NetworkTransforms and rotation can occur on both the parent and child. When quaternion synchronization is enabled, the entire quaternion is updated when there are any changes to any axial values. You can use half float precision or quaternion compression to reduce the bandwidth cost.
UseHalfFloatPrecision
When set, the NetworkTransform will use half float precision for position, rotation, and scale.
Declaration
public bool UseHalfFloatPrecision { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Postion is synchronized through delta position updates in order to reduce precision loss/drift and to extend to positions beyond the limitation of half float maximum values. Rotation and scale both use half float precision (HalfVector4 and HalfVector3)
UseInterpolation
When set the NetworkTransform is uses interpolation.
Declaration
public bool UseInterpolation { get; }
Property Value
Type | Description |
---|---|
bool |
Remarks
Authority does not apply interpolation via NetworkTransform. Authority should handle its own motion/rotation/scale smoothing locally.
UsePositionSlerp
Determines if position interpolation will Slerp towards its target position. This is only really useful if you are moving around a point in a circular pattern.
Declaration
public bool UsePositionSlerp { get; }
Property Value
Type | Description |
---|---|
bool |
Methods
GetNetworkTick()
The network tick that this state was sent by the authoritative instance.
Declaration
public int GetNetworkTick()
Returns
Type | Description |
---|---|
int |
GetPosition()
Returns the current state's position. If there is no change in position, then it returns zero.
Declaration
public Vector3 GetPosition()
Returns
Type | Description |
---|---|
Vector3 |
Remarks
When there is no change in an updated state's position then there are no values to return. Checking for HasPositionChange is one way to detect this. When used with half precision it returns the half precision delta position state update which will not be the full position. To get a NettworkTransform's full position, use GetSpaceRelativePosition(bool) and pass true as the parameter.
GetRotation()
Returns the current state's rotation. If there is no change in the rotation, then it will return identity.
Declaration
public Quaternion GetRotation()
Returns
Type | Description |
---|---|
Quaternion |
Remarks
When there is no change in an updated state's rotation then there are no values to return. Checking for HasRotAngleChange is one way to detect this.
GetScale()
Returns the current state's scale. If there is no change in scale, then it returns zero.
Declaration
public Vector3 GetScale()
Returns
Type | Description |
---|---|
Vector3 |
Remarks
When there is no change in an updated state's scale then there are no values to return. Checking for HasScaleChange is one way to detect this.
IsReliableStateUpdate()
Returns true if this state was sent with reliable delivery. If false, then it was sent with unreliable delivery.
Declaration
public bool IsReliableStateUpdate()
Returns
Type | Description |
---|---|
bool |
Remarks
Unreliable delivery will only be used if UseUnreliableDeltas is set.
IsUnreliableFrameSync()
Returns whether this state update was a frame synchronization when UseUnreliableDeltas is enabled. When set, the entire transform will be or has been synchronized.
Declaration
public bool IsUnreliableFrameSync()
Returns
Type | Description |
---|---|
bool |
NetworkSerialize<T>(BufferSerializer<T>)
Serializes this NetworkTransform.NetworkTransformState
Declaration
public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter
Parameters
Type | Name | Description |
---|---|---|
BufferSerializer<T> | serializer |
Type Parameters
Name | Description |
---|---|
T |