Struct NetworkTransform.NetworkTransformState
Data structure used to synchronize the NetworkTransform
Inherited Members
Namespace: Unity.Netcode.Components
Syntax
public struct NetworkTransformState : INetworkSerializable
Properties
HasPositionChange
When set, at least one of the position axis values has changed.
Declaration
public readonly bool HasPositionChange { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasPositionX
When set, the X-Axis position value has changed
Declaration
public bool HasPositionX { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasPositionY
When set, the Y-Axis position value has changed
Declaration
public bool HasPositionY { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasPositionZ
When set, the Z-Axis position value has changed
Declaration
public bool HasPositionZ { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasRotAngleChange
When set, at least one of the rotation axis values has changed.
Declaration
public readonly bool HasRotAngleChange { get; }
Property Value
Type | Description |
---|---|
Boolean |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
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 readonly bool HasScaleChange { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasScaleX
When set, the X-Axis scale value has changed.
Declaration
public bool HasScaleX { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasScaleY
When set, the Y-Axis scale value has changed.
Declaration
public bool HasScaleY { get; }
Property Value
Type | Description |
---|---|
Boolean |
HasScaleZ
When set, the Z-Axis scale value has changed.
Declaration
public bool HasScaleZ { get; }
Property Value
Type | Description |
---|---|
Boolean |
InLocalSpace
When set, the NetworkTransform is operates in local space
Declaration
public bool InLocalSpace { get; }
Property Value
Type | Description |
---|---|
Boolean |
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 |
---|---|
Boolean |
IsTeleportingNextFrame
When set, the current state will be treated as a teleport.
Declaration
public bool IsTeleportingNextFrame { get; }
Property Value
Type | Description |
---|---|
Boolean |
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 int LastSerializedSize { readonly get; }
Property Value
Type | Description |
---|---|
Int32 |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
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 |
---|---|
Boolean |
Methods
GetNetworkTick()
The network tick that this state was sent by the authoritative instance.
Declaration
public int GetNetworkTick()
Returns
Type | Description |
---|---|
Int32 | Int32 |
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 | 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.
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 | 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 | 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.
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 |