Struct GhostField<InternalTypeT>
The main way to sync state. This data will be replicated to other ghosts in an eventually consistent way. This means a client doesn't have a guarantee to receive all the different state changes, only that it'll eventually have the latest state. Your data will be rolled back automatically when running prediction. You can specify various serialization options using the FieldConfig parameter in the GhostField<InternalTypeT> constructor. Please refer to RPCs for volatile networked events. TODO-next@RPCs link to RPC doc
Inherited Members
Namespace: Unity.Netcode
Assembly: Unity.NetCode.dll
Syntax
[Serializable]
public struct GhostField<InternalTypeT> where InternalTypeT : unmanaged
Type Parameters
| Name | Description |
|---|---|
| InternalTypeT | The unmanaged type of the replicated value. |
Constructors
GhostField(InternalTypeT, FieldConfig)
Declaration
public GhostField(InternalTypeT initialValue = default, FieldConfig fieldConfig = null)
Parameters
| Type | Name | Description |
|---|---|---|
| InternalTypeT | initialValue | The value the field holds until it is linked to its ghost entity. |
| FieldConfig | fieldConfig | Serialization options used by source generators. |
Properties
Value
Access your stored networked value. Optional: To access ECS Component data from ECS systems, please use GhostComponentRef<TComponentType>
Declaration
public InternalTypeT Value { get; set; }
Property Value
| Type | Description |
|---|---|
| InternalTypeT |