Class NetworkTransformChild
A component to synchronize the position of child transforms of networked objects.
There must be a NetworkTransform on the root object of the hierarchy. There can be multiple NetworkTransformChild components on an object. This does not use physics for synchronization, it simply synchronizes the localPosition and localRotation of the child transform and lerps towards the recieved values.
Inherited Members
Namespace: UnityEngine.Networking
Assembly: com.unity.multiplayer-hlapi.Runtime.dll
Syntax
[AddComponentMenu("Network/NetworkTransformChild")]
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public class NetworkTransformChild : NetworkBehaviour
Properties
childIndex
A unique Identifier for this NetworkTransformChild component on this root object.
Declaration
public uint childIndex { get; }
Property Value
Type | Description |
---|---|
uint |
clientMoveCallback3D
A callback function to allow server side validation of the movement of the child object.
Declaration
public NetworkTransform.ClientMoveCallback3D clientMoveCallback3D { get; set; }
Property Value
Type | Description |
---|---|
NetworkTransform.ClientMoveCallback3D |
interpolateMovement
The rate to interpolate towards the target position.
A value of 1 will snap to the position, and lower positive values will interpolate more slowly.
Declaration
public float interpolateMovement { get; set; }
Property Value
Type | Description |
---|---|
float |
interpolateRotation
The rate to interpolate to the target rotation.
A value of 1 will snap to the position, and lower positive values will interpolate more slowly.
Declaration
public float interpolateRotation { get; set; }
Property Value
Type | Description |
---|---|
float |
lastSyncTime
The most recent time when a movement synchronization packet arrived for this object.
Declaration
public float lastSyncTime { get; }
Property Value
Type | Description |
---|---|
float |
movementThreshold
The distance that an object can move without sending a movement synchronization update.
This applies to the child object's localPosition, not it's world position.
Declaration
public float movementThreshold { get; set; }
Property Value
Type | Description |
---|---|
float |
rotationSyncCompression
How much to compress rotation sync updates.
Declaration
public NetworkTransform.CompressionSyncMode rotationSyncCompression { get; set; }
Property Value
Type | Description |
---|---|
NetworkTransform.CompressionSyncMode |
sendInterval
The sendInterval controls how often state updates are sent for this object.
Declaration
public float sendInterval { get; set; }
Property Value
Type | Description |
---|---|
float |
syncRotationAxis
Which axis should rotation by synchronized for.
Declaration
public NetworkTransform.AxisSyncMode syncRotationAxis { get; set; }
Property Value
Type | Description |
---|---|
NetworkTransform.AxisSyncMode |
target
The child transform to be synchronized.
Declaration
public Transform target { get; set; }
Property Value
Type | Description |
---|---|
Transform |
targetSyncPosition
The target position interpolating towards.
Declaration
public Vector3 targetSyncPosition { get; }
Property Value
Type | Description |
---|---|
Vector3 |
targetSyncRotation3D
The target rotation interpolating towards.
Declaration
public Quaternion targetSyncRotation3D { get; }
Property Value
Type | Description |
---|---|
Quaternion |
Methods
GetNetworkChannel()
This virtual function is used to specify the QoS channel to use for SyncVar updates for this script.
Using the NetworkSettings custom attribute causes this function to be implemented for this script, but developers can also implement it themselves.
Declaration
public override int GetNetworkChannel()
Returns
Type | Description |
---|---|
int | The QoS channel for this script. |
Overrides
GetNetworkSendInterval()
This virtual function is used to specify the send interval to use for SyncVar updates for this script.
Using the NetworkSettings custom attribute causes this function to be implemented for this script, but developers can also implement it themselves.
Declaration
public override float GetNetworkSendInterval()
Returns
Type | Description |
---|---|
float | The time in seconds between updates. |
Overrides
OnDeserialize(NetworkReader, bool)
Virtual function to override to receive custom serialization data. The corresponding function to send serialization data is OnSerialize().
Declaration
public override void OnDeserialize(NetworkReader reader, bool initialState)
Parameters
Type | Name | Description |
---|---|---|
NetworkReader | reader | Reader to read from the stream. |
bool | initialState | True if being sent initial state. |
Overrides
OnSerialize(NetworkWriter, bool)
Virtual function to override to send custom serialization data. The corresponding function to send serialization data is OnDeserialize().
The initialState flag is useful to differentiate between the first time an object is serialized and when incremental updates can be sent. The first time an object is sent to a client, it must include a full state snapshot, but subsequent updates can save on bandwidth by including only incremental changes. Note that SyncVar hook functions are not called when initialState is true, only for incremental updates.
If a class has SyncVars, then an implementation of this function and OnDeserialize() are added automatically to the class. So a class that has SyncVars cannot also have custom serialization functions.
The OnSerialize function should return true to indicate that an update should be sent. If it returns true, then the dirty bits for that script are set to zero, if it returns false then the dirty bits are not changed. This allows multiple changes to a script to be accumulated over time and sent when the system is ready, instead of every frame.
Declaration
public override bool OnSerialize(NetworkWriter writer, bool initialState)
Parameters
Type | Name | Description |
---|---|---|
NetworkWriter | writer | Writer to use to write to the stream. |
bool | initialState | If this is being called to send initial state. |
Returns
Type | Description |
---|---|
bool | True if data was written. |