Struct NetworkDeltaPosition
Used to synchromnize delta position when half float precision is enabled
Inherited Members
Namespace: Unity.Netcode.Components
Syntax
public struct NetworkDeltaPosition : INetworkSerializable
Constructors
NetworkDeltaPosition(Single, Single, Single, Int32)
Constructor
Declaration
public NetworkDeltaPosition(float x, float y, float z, int networkTick)
Parameters
Type | Name | Description |
---|---|---|
Single | x | The initial x axis (converted to half float) value when instantiated. |
Single | y | The initial y axis (converted to half float) value when instantiated. |
Single | z | The initial z axis (converted to half float) value when instantiated. |
Int32 | networkTick | Set the network tick value to the current network tick when instantiating. |
NetworkDeltaPosition(Single, Single, Single, Int32, bool3)
Constructor
Declaration
public NetworkDeltaPosition(float x, float y, float z, int networkTick, bool3 axisToSynchronize)
Parameters
Type | Name | Description |
---|---|---|
Single | x | The initial x axis (converted to half float) value when instantiated. |
Single | y | The initial y axis (converted to half float) value when instantiated. |
Single | z | The initial z axis (converted to half float) value when instantiated. |
Int32 | networkTick | Set the network tick value to the current network tick when instantiating. |
bool3 | axisToSynchronize | The axis to be synchronized. |
NetworkDeltaPosition(Vector3, Int32)
Constructor that defaults to all axis being synchronized.
Declaration
public NetworkDeltaPosition(Vector3 vector3, int networkTick)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector3 | The initial axial values (converted to half floats) when instantiated. |
Int32 | networkTick | Set the network tick value to the current network tick when instantiating. |
NetworkDeltaPosition(Vector3, Int32, bool3)
Constructor
Declaration
public NetworkDeltaPosition(Vector3 vector3, int networkTick, bool3 axisToSynchronize)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector3 | The initial axial values (converted to half floats) when instantiated. |
Int32 | networkTick | Set the network tick value to the current network tick when instantiating. |
bool3 | axisToSynchronize | The axis to be synchronized. |
Fields
HalfVector3
The HalfVector3 used to synchronize the delta in position
Declaration
public HalfVector3 HalfVector3
Field Value
Type | Description |
---|---|
HalfVector3 |
Methods
GetConvertedDelta()
The half float vector3 version of the current delta position.
Declaration
public Vector3 GetConvertedDelta()
Returns
Type | Description |
---|---|
Vector3 |
Remarks
Only applies to the authoritative side for NetworkTransform instances.
GetCurrentBasePosition()
Returns the current base position (excluding the delta position offset).
Declaration
public Vector3 GetCurrentBasePosition()
Returns
Type | Description |
---|---|
Vector3 | The current base position as a Vector3 |
GetDeltaPosition()
The full precision current delta position.
Declaration
public Vector3 GetDeltaPosition()
Returns
Type | Description |
---|---|
Vector3 |
Remarks
Authoritative: Will have no precision loss Non-Authoritative: Has the current network tick's loss of precision. Precision loss adjustments are one network tick behind on the non-authoritative side.
GetFullPosition()
Returns the full position which includes the delta offset position.
Declaration
public Vector3 GetFullPosition()
Returns
Type | Description |
---|---|
Vector3 | The full position as a Vector3. |
NetworkSerialize<T>(BufferSerializer<T>)
The serialization implementation of INetworkSerializable
Declaration
public void NetworkSerialize<T>(BufferSerializer<T> serializer)
where T : IReaderWriter
Parameters
Type | Name | Description |
---|---|---|
BufferSerializer<T> | serializer |
Type Parameters
Name | Description |
---|---|
T |
Implements
ToVector3(Int32)
Gets the full precision value of Vector3 position while also potentially updating the current base position.
Declaration
public Vector3 ToVector3(int networkTick)
Parameters
Type | Name | Description |
---|---|---|
Int32 | networkTick | Use the current network tick value. |
Returns
Type | Description |
---|---|
Vector3 | The full position as a Vector3. |
UpdateFrom(ref Vector3, Int32)
Updates the position delta based off of the current base position.
Declaration
public void UpdateFrom(ref Vector3 vector3, int networkTick)
Parameters
Type | Name | Description |
---|---|---|
Vector3 | vector3 | The full precision Vector3 value to (converted to half floats) used to determine the delta offset positon. |
Int32 | networkTick | Set the current network tick value when updating. |