Namespace Unity.NetCode
Classes
AutomaticThinClientWorldsUtility
Have netcode automatically manage thin clients for you by assigning Num
BatchPredictAttribute
When using MaxPredictionStepBatchSize the client will batch prediction steps, but it will normally break the batches when input changes. If this attribute is placed on an input in the ICommandData / IInputComponentData component changes to the field marked with this attribute will not break batches. This can be used for example to make sure mouse look input changes can be batched while starting to move cannot be batched.
BufferSerializationHelper<TComponentType, TSnapshot, TSerializer>
Helper class used by code-gen to setup the serialisation function pointers.
ClientOnlyVariant
Special universal component variant that can be assigned to any component and/or buffer when configuring the GhostComponentSerializerCollectionSystemGroup. Mostly used for stripping components from the server-side ghost prefabs.
To use this for your own types: Set it as the default in your own Register
ClientServerBootstrap
ClientServerBootstrap is responsible for configuring and creating the server and client worlds at runtime when
the game starts (or when entering Play Mode in the Editor).
ClientServerBootstrap is intended as a base class for your own custom bootstrap code and provides utility methods
for creating the client and server worlds.
It also supports connecting the client to the server automatically, using the Auto
ClientServerWorldExtensions
Netcode-specific extension methods for worlds.
CommandDataUtility
Contains utility methods to add and retrieve commands from ICommand
CommandReceiveSystemGroup
Group that contains all systems that receives commands. Only present in server world.
CommandSendSystemGroup
Parent group of all systems that serialize ICommand
CompareCommandSystemGroup
This group contains all core-generated system that are used to compare commands for sake of identifing the ticks the client
has changed input (see m_Unique
ComponentSerializationHelper<TComponentType, TSnapshot, TSerializer>
Helper class used by code-gen to setup the serialisation function pointers.
CopyCommandBufferToInputSystemGroup
The parent group for all generated systems that copy data from and underlying Input
CopyInputToCommandBufferSystemGroup
The parent group for all generated systems that copy data from the an IInput
DebugGhostDrawer
Allows game code to write its own custom ghost drawers and hook them up in the MultiplayerPlayModeWindow
.
Implement your own DebugBoundingBoxDebugGhostDrawer
for reference.
DebugGhostDrawer.CustomDrawer
Allows game code to write its own custom ghost drawers and hook them up in the MultiplayerPlayModeWindow
.
Implement your own DebugBoundingBoxDebugGhostDrawer
for reference.
DefaultDriverBuilder
Default helper method implementation for constructing Network
DefaultSmoothingActionUserParamsAuthoring
Authoring component which adds the maxDist component to the Entity.
DefaultTranslationSmoothingAction.DefaultStaticUserParams
The default value for the Default
DefaultVariantSystemBase
DefaultVariantSystemBase is an abstract base class that should be used to update the default variants in
Ghost
The system must (and will be) created in both runtime and baking worlds. During baking, in particular,
the Ghost
The abstract base class already has the correct flags / update in world attributes set.
It is not necessary for the concrete implementation to specify the flags, nor the World
CREATION FLOW
All the default variant systems must be created after the Ghost
DefaultVariantSystemGroup
Group that contains all the systems responsible for registering/setting up the default Ghost Variants (see GhostOnCreate
method, by collecting from all the registered
Default
DisableAutomaticPrespawnSectionReportingAuthoring
Authoring component which adds the DisableAutomaticPrespawnSectionReporting component to the Entity.
DontSerializeForCommandAttribute
Add the attribute to prevent a field ICommandData struct to be serialized.
DontSerializeVariant
Special universal component variant that can be assigned to any component and/or buffer. When a component serializer is set to DontSerializeVariant, the component itself is not stripped from the client or server version of the prefab, but at runtime it is not serialized (and thus not sent to the clients).
DontSupportPrefabOverridesAttribute
Use this attribute to prevent a GhostComponent from supporting any kind of variants or PrefabType overrides.
Hides this component in the GhostAuthoringInspectionComponent
window.
Mutually exclusive to Supports
DriverMigrationSystem
A system that should be used to temporarly keep the internal transport connections alive while transferring then to another world. For example, you can rely on the DriverMigrationSystem to re-use the same connections in between a lobby world and the game world.
GhostAuthoringComponent
The GhostAuthoringComponent is the main entry point to configure and create replicated ghosts types. The component must be added only to the GameObject hierarchy root.
It allows setting all ghost properties,
such as the replication mode Supported
GhostAuthoringInspectionComponent
MonoBehaviour you may optionally add to any/all GameObjects in a Ghost Prefab, which allows inspecting of (and saving of) "Ghost Meta Data". E.g.
- Override/Tweak some of the component replication properties, for both child and root entities.
- Assign to each component which variant to use.
GhostComponentAttribute
This attribute can be used to tag components to control which ghost prefab variants they are included in and where they are sent for owner predicted ghosts.
GhostComponentSerializerCollectionSystemGroup
Parent group of all code-generated systems that registers the ghost component serializers to the Ghost
GhostComponentUtilities
Utility methods for working with GhostComponents.
GhostComponentVariationAttribute
Generate a serialization variant for a component using the Ghost
Note: This is incompatible with any type implementing Dont
GhostEnabledBitAttribute
Attribute denoting that an IEnableable
GhostFieldAttribute
Attribute used to specify how and which fields and properties of IComponent
GhostFieldSubType
Hold a list of constant int that can be used across the project to specify
subtype in Ghost
GhostInputSystemGroup
The parent group for all input gathering systems. Only present in client worlds
(and local worlds, to allow singleplayer to use the same input gathering system).
It runs before the Command
GhostPrefabCreation
Helper methods and structs used to configure and create ghost prefabs
GhostSerializerAttribute
For internal use only. Markup for the generate component/buffer code-generated serializer, added automatically by the code-generation system.
GhostSimulationSystemGroup
Present for both client and server worlds (and Local, for singleplayer input support). This is the core group, and contains the majority of the netcode systems. Its responsibilities are varied, and can be roughly sub-divided in the following categories:
-input gathering: Ghost
-command handling: Command
-ghost prediction/simulation: Predicted
-ghost spawning: see Ghost
-ghost replication: Ghost
In general, all systems that need to simulate/manipulate ghost entities should be added to this group.
GhostSpawnClassificationSystemGroup
Contains all the system that classify spawned ghost. Runs after the Ghost
[UpdateInGroup(typeof(GhostSpawnClassificationSystemGroup))]
public partial struct MyCustomClassificationSystemGroup
{
...
}
GhostSpawnSystemGroup
Parent group of all systems that need to process ghost entities after they are spawned.
The group execute before Network
GhostVariantsUtility
Collection of utility that are used by the editor and runtime to compute and check ghost component variants hashes.
HostMigration
Host migration class used to access the host migration system, like getting the host migration data blob and functions for reacting to host migration events.
MultiplayerPlayModePreferences
Developer preferences for the MultiplayerPlayModeWindow
. Only applicable in editor.
NetCodeConfig
Config file, allowing the package user to tweak netcode variables without having to write code. Create as many instances as you like.
NetCodeDebugConfigAuthoring
Add this component to a gameobject present in a sub-scene to configure the Net
NetCodeDisableCommandCodeGenAttribute
This attribute is used to disable code generation for a struct implementing ICommandData or IRpcCommand
NetCodeUtils
ToFixedString utilities for enums.
NetcodeBitArrayExtensions
For Unsafe
NetcodeServerRateManager
Server world's main update rate manager. Determines whether simulation system group should run or not, depending on tick rate and accumulator logic.
NetworkGroupCommandBufferSystem
The Entity
NetworkIdDebugColorUtility
A collection of utility to assign constant colors for the NetworkId's. There are in total 13 unique colors, with 14+ mapping to the original.
NetworkReceiveSystemGroup
Parent group of all systems that; receive data from the server, deal with connections, and
that need to perform operations before the ghost simulation group.
In particular, Command
NetworkSimulatorSettings
In the Editor, Multiplayer
OverrideAutomaticNetcodeBootstrap
Add this to your Scene (on a root GameObject only!) to replace the automatic bootstrapping setting specified in
your Net
PredictedFixedStepSimulationSystemGroup
A fixed update group inside the ghost prediction. This is equivalent to Fixed
Note: This SystemGroup is intentionally added to non-netcode worlds, to help enable single-player testing.
PredictedSimulationSystemGroup
The parent group for all (roughly) deterministic gameplay systems that modify predicted ghosts.
This system group runs for both the client and server worlds at a fixed time step, as specified by
the Simulation
On the server, this group is only updated once per tick, because it runs in tandem with the Simulation
Important: Because the client is predicting ahead of the server, all systems in this group are updated multiple times
per simulation frame, every time the client receives a new snapshot (see Network
These re-simulation prediction group ticks also get more frequent at higher pings.
For example, a client with a 200ms ping is likely to re-simulate roughly twice as many frames than a client with a 100ms connection, with caveats.
The number of predicted, re-simulated frames can easily reach double digits, so systems in this group
must be exceptionally fast, and are likely to use a lot of CPU.
You can use prediction group batching to help mitigate this. Refer to Max
This group contains all predicted simulation (simulation that is the same on both client and server). On the server, all prediction logic is treated as the authoritative game state, which is only simulated once.
Note: This SystemGroup is intentionally added to non-netcode worlds, to help enable single-player testing.
PrespawnGhostSystemGroup
The PrespawnGhostSystemGroup contains all the systems related to pre-spawned ghost.
RpcCommandRequestSystemGroup
A group used to make sure all processing on command request entities happens in the correct place. This is used by code-gen and should only be used directly when implementing custom command request processors.
ServerOnlyVariant
Special universal component variant that can be assigned to any component and/or buffer when configuring the GhostComponentSerializerCollectionSystemGroup. Mostly used for stripping components from the client-side ghost prefabs.
To use this for your own types: Set it as the default in your own Register
SupportsPrefabOverridesAttribute
Use this attribute to allow a GhostComponent to support any kind of Ghost variation.
Mutually exclusive to Dont
TransformDefaultVariantSystem
System that optionally setup the Netcode default variants used for transform components in case a default is not already present. The following variants are set by default by the package:
- Unity.
Transforms. Local Transform - Unity.Transforms.Translation
- Unity.Transforms.Rotation
Structs
ApplyCurrentInputBufferElementToInputDataSystem<TInputComponentData, TInputHelper>
For internal use only, system that copies commands from the Input
ApplyCurrentInputBufferElementToInputData<TInputBufferData, TInputComponentData>
For internal use only, helper struct that should be used to implements systems that copies
commands from the ICommand
ApplyCurrentInputBufferElementToInputData<TInputBufferData, TInputComponentData>.ApplyInputDataFromBufferJob
Helper struct that should be used to implement jobs that copies commands from an ICommand
ApplyInputDataFromBufferJob<TInputComponentData, TInputHelper>
Internal job (don't use directly), run inside the prediction loop and copy the
input data from an Input
AutoCommandTarget
Component that automates command "reading and sending" (for clients) or "writing, using, and broadcasting" (for the server).
When the AutoCommandTarget component is Enabled, the entity is considered as an input source
for ICommand
On the server side, when a command is deserialized from the Incoming
ClientPopulatePrespawnedGhostsSystem
Responsible for assigning a unique ghost
ClientServerTickRate
The ClientServerTickRate singleton is used to configure the client and server simulation time step,
server packet send rate and other related settings.
The singleton entity is automatically created for the clients in the Network
- Create the entity in a custom Unity.NetCode.ClientServerBootstrap after the worlds has been created.
- On a system, in either the OnCreate or OnUpdate.
- the maximum number of tick per frame
- the maximum number of tick per frame
- tick batching (<`MaxSimulationStepBatchSize`) and others.
ClientTickRate
Create a ClientTickRate singleton in the client world (either at runtime or by loading it from sub-scene) to configure all the network time synchronization, interpolation delay, prediction batching and other setting for the client. See the individual fields for more information about the individual properties.
ClientTrackLoadedPrespawnSections
The ClientTrackLoadedPrespawnSections is responsible for tracking when a scene section is unloaded and removing the pre-spawned ghosts from the client ghosts maps
CommandArrivalStatistics
Stores statistics pertaining to the frequency and reliability of received commands from a client. Thus, only valid on the server. May help you diagnose input/command issues.
CommandDataInterpolationDelay
Optional component used to access the interpolation delay in order to implement lag compensation on the server. Also exists on predicted clients (but the interpolation delay will always be 0).
The component is not baked during conversion by default, and should be added explicitly by the user at one of two points:
1. At conversion time: By using the checkbox in `GhostAuthoringComponent` or your own Baker.
2. At runtime: After the entity is spawned.
CommandReceiveSystem<TCommandDataSerializer, TCommandData>
Helper struct for implementing systems to receive commands. This is generally used by code-gen and should only be used directly in special cases.
CommandReceiveSystem<TCommandDataSerializer, TCommandData>.ReceiveJobData
Helper struct used by code-gen for implementing the Execute method of the the generated receiving job.
The ReceiveJobData implement the command deserialization logic, by reading from the data stream the
serialized commands and enqueuing them into the taget entity command buffer.
As part of the command deserialization, if a Command
CommandSendSystem<TCommandDataSerializer, TCommandData>
Helper struct for implementing systems to send commands. This is generally used by code-gen and should only be used directly in special cases.
CommandSendSystem<TCommandDataSerializer, TCommandData>.SendJobData
Helper struct used by code-generated command job to serialize the ICommand
CommandTarget
Component added to all Network
- You are not using the AutoCommandTarget.
- You want to support thin-clients (because AutoCommandTarget does not work in that case) The use of AutoCommandTarget and CommandTarget is complementary. I.e. They can both be used at the same time.
CommandTargetComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
ComponentTypeSerializationStrategy
For internal use only. Stores individual "serialization strategies" (and meta-data) for all netcode-informed components,
as well as all variants of these components (Ghost
Note: Serializers are considered "optional". It is perfectly valid for a types "serialization strategy" to be: "Do nothing".
An example of this is a component for which a variant has been declared (using the Ghost
ConcurrentDriverStore
The concurrent version of the DriverStore. Contains the concurrent copy of the drivers and relative pipelines.
ConnectionApproved
Add this component to a ServerWorld network connection entity, to denote that it has been approved by your logic. It will be added automatically on the client, once the connection is approved.
ConnectionState
An optional cleanup component that can be added to a newly created connection to monitor its state changes.
Must be added and removed by the gameplay logic. When the Connection
ConvertPredictionEntry
Struct storing settings for an individual queue entry in the Ghost
CopyInputToBufferJob<TInputComponentData, TInputHelper>
Internal job (don't use directly) used to copy the input data for struct implementing the
IInput
CopyInputToCommandBufferSystem<TInputComponentData, TInputHelper>
For internal use only, system that that copy the content of an IInput
CopyInputToCommandBuffer<TInputBufferData, TInputComponentData>
For internal use only, helper struct that should be used to implement systems that copy the content of an
IInput
CopyInputToCommandBuffer<TInputBufferData, TInputComponentData>.CopyInputToBufferJob
For internal use only, simplify the creation of system jobs that copies IInput
DefaultSmoothingActionUserParams
Add the DefaultSmoothingActionUserParams component to customise on a per-entity basis the prediction error range in which the position smoothing is active.
DefaultTranslationSmoothingAction
The default prediction error Smoothing
DefaultVariantSystemBase.Rule
When defining default variants for a type, you must denote whether or not this variant will be applied to both parents and children.
DisableAutomaticPrespawnSectionReporting
Singleton component used to enable/disable the built-in scene auto-tracking.
DisconnectReasonEnumToString
Convert disconnection reason error code into human readable error messages.
EnableHostMigration
Enable the host migration feature. This will enable the host migration systems and is required for host migration to work.
EnablePacketLogging
Add this component to any connection entities (i.e. entities with the Network
GameProtocolVersion
The game specific version to use for protocol validation when the client and server connects.
If a singleton with this component does not exist 0 will be used instead.
Protocol validation will still validate the Net
GhostChildEntity
A tag added to child entities in a ghost with multiple entities. It should also be added to ghosts in a group if the ghost is not the root of the group.
GhostChildEntityComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
GhostCollection
A component used to identify the singleton which owns the ghost collection lists and data. The singleton contains buffers for GhostCollectionPrefab, GhostCollectionPrefabSerializer, GhostCollectionComponentIndex and GhostComponentSerializer.State
GhostCollectionComponentIndex
This list contains the set of entity + component for all serialization rules in GhostCollectionPrefabSerializer. GhostCollectionPrefabSerializer contains a FirstComponent and NumComponents which identifies the set of components to use from this array. Added to the GhostCollection singleton entity.
GhostCollectionCustomSerializers
Singleton component that holds the list of custom chunk serializers.
GhostCollectionPrefab
A list of all prefabs which can be used for ghosts. This is populated with all ghost prefabs on the server and that list is sent for clients. Having a prefab in this list does not guarantee that there is a serializer for it yet. Added to the GhostCollection singleton entity.
GhostCollectionPrefabSerializer
A list of all serializer data for the prefabs in GhostCollectionPrefab. This list can be shorter if not all serializers are created yet. Added to the GhostCollection singleton entity.
GhostCollectionSystem
System responsible to construct and manage the Ghost
The system processes all the ghost prefabs present in the world by:
- stripping and removing components from the entity prefab based on Ghost
- populating the Ghost
- preparing and constructing all the necessary data structure (Ghost
GhostComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
GhostComponentSerializerCollectionData
Blittable. Ghost
GhostConnectionPosition
Add this component to each connection to determine which tiles the connection should prioritize.
This will be passed as argument to the built-in scale function to compute Importance.
See Ghost
GhostCount
Singleton component with APIs and collections required for Ghost counting.
GhostDebugMeshBounds
Self contained component to hold a mesh's bounds for debug drawing.
GhostDeltaPredictor
For internal use only. Used by the ghost component serializer to calculate (predict) the new value for a field, given the two previous baseline values.
This value provides a good estimate for current value of a variable when changes are linear or otherwise predictable. I.e. Small deltas have good compression ratios.
GhostDeserializerState
Inter-op struct used to pass arguments to the ghost component serializers (see Ghost
GhostDespawnSystem
Present only in client worlds. Responsible for destroying spawned ghosts when a despawn request/command is received from the server.
Clients are not responsible for destroying ghost entities (and thus should never). The server is responsible for notifying the client about which ghosts should be destroyed (as part of the snapshot protocol).
When a despawn command is received, the ghost entity is queued into a despawn queue. Two distinct despawn queues exist: one for interpolated, and one for the predicted ghosts.
The above distinction is necessary because interpolated ghosts timeline (Interpolation
Predicted entities, on the other hand, can be despawned only when the current Server
GhostDistanceData
The default configuration data for Ghost
GhostDistanceImportance
Computes distance based importance scaling.
I.e. Entities far away from a clients importance focal point (via Ghost
GhostDistancePartitionShared
Index information per entity used for distance based Importance scaling.
GhostDistancePartitioningSystem
Computes index for each entity. The translation is used to compute the right tile index to assign to the Ghost
GhostGroup
Similar to Linked
GhostImportance
Singleton component used to control importance settings
GhostInstance
Component signaling an entity which is replicated over the network
GhostMetrics
A list of serialized ghosts metrics.
GhostMetricsMonitor
Present on both client and server world, singleton component that enables monitoring of ghost metrics.
GhostMetricsMonitorComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
GhostNames
A list of all currently available Ghosts.
This list maps 1-1 with Ghost
GhostOwner
The GhostOwnerComponent is an optional component that can be added to a ghost to create a bond/relationship in
between an entity and a specific client (for example, the client who spawned that entity, a bullet, the player entity).
It is usually added to predicted ghost (see Predicted
It is mandatory to add a Ghost
- When a ghost is configured to be owner-predicted Ghost
- If you want to enable remote player prediction (see ICommand
- If you want to use the Auto
GhostOwnerComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
GhostOwnerIsLocal
An enableable tag component used to track if a ghost with an owner is owned by the local host or not. This is enabled for all ghosts on the server and for ghosts where the ghost owner network id matches the connection id on the client.
GhostPredictionDebugSystem
GhostPredictionHistorySystem
A system used to make a backup of the current predicted state, right after the last full (not fractional) tick in a prediction loop for a frame has been completed. The backup does a memcopy of all ghost components (into a separate memory area connected to the chunk). The backup is used to restore the last full tick, to continue prediction when no new data has arrived. Note: When this happens, only the fields which are actually serialized as part of the snapshot are copied back, not the full component. Thus, preserving any non-GhostField state. The backup data is also used to:
- Detect errors in the prediction.
- To add smoothing of predicted values.
GhostPredictionSmoothing
Singleton used to register a Smoothing
- A smoothing action without argument. See Register
- A smoothing action that take a component data as argument. See Register
GhostPredictionSmoothingSystem
System that corrects the client prediction errors, by applying the smoothing actions
registerd to the Ghost
GhostPredictionSwitchingQueues
Singleton component with APIs and collections required for converting client ghosts Ghost
GhostPredictionSwitchingSystem
System that applies the prediction switching on the queued entities (via Ghost
GhostPrefabCreation.Component
Identifier for a specific component type on a specific child of a ghost prefab.
GhostPrefabCreation.ComponentOverride
A modifier for a specific component on a specific child entity. Only the override types specified by the OverrideType are applied, the others are ignored.
GhostPrefabCreation.Config
Configuration used to create a ghost prefab.
GhostPrefabCustomSerializer
Allow to associate for a given ghost prefab a custom made (hand written) serialization function.
The method allow to serialize on per "archetype", allowing for better vectorization and optimisation in general.
However, writing the serialization code is not trivial and require deep knowledge of the underlying
Ghost
GhostPrefabCustomSerializer.Context
Contains all the necessary data to perform the chunk serialization.
GhostReceiveSystem
System present only in clients worlds, receive and decode the ghost snapshosts sent by the server.
When a new snapshost is received, the system will start decoding the packet protocol by extracting:
-the list of ghost that need to despawned
-for each serialized ghost, it delta-compressed or uncompressed state
The system will schedule spawning and despawning ghosts requests, by using
the Ghost
When a new state snapshot is received for a ghost that has been already spawned (see Spawned
The received snapshot are recorded into the Network
GhostRelevancy
Singleton entity present on the server. Every frame, collect the set of ghosts that should be (or should not be) replicated to a given client.
GhostSendSystem
System present only for servers worlds, and responsible to replicate ghost entities to the clients.
The Ghost
Ghosts entities are replicated by sending a 'snapshot' of their state to the clients, at Network
The GhostSendSystem is designed to send to each connection one single packet per network update. By default, the system will try to replicate to the clients all the existing ghost present in the world. When all ghosts cannot be serialized into the same packet, the enties are prioritized by their importance.
The base ghost importance can be set at authoring time on the prefab (Unity.NetCode.GhostAuthoringComponent); At runtime the ghost importance is scaled based on:
- age (the last time the entities has been sent)
- scaled by distance, (see Ghost
- scaled by custom scaling (see Ghost
Ghost entities are replicated on "per-chunk" basis; all ghosts for the same chunk, are replicated together. The importance, as well as the importance scaling, apply to whole chunk.
The send system can also be configured to send multiple ghost packets per frame and to to use snaphost larger than the MaxMessageSize.
In that case, the snapshot packet is sent using another unreliable channel, setup with a Unity.
GhostSendSystemData
Singleton entity that contains all the tweakable settings for the Ghost
GhostSerializationMetrics
Monitor serialization timings of ghosts.
GhostSerializerState
For internal use only, struct used to pass some data to the code-generate ghost serializer.
GhostSpawnBuffer
The GhostSpawnBuffer is the data for a GhostSpawnQueue singleton. It contains a list of ghosts which will be spawned by the GhostSpawnSystem at the beginning of next frame. It is populated by the GhostReceiveSystem and there needs to be a classification system updating after the GhostReceiveSystem which sets the SpawnType so the spawn system knows how to spawn the ghost. A classification system should only modify the SpawnType and PredictedSpawnEntity fields of this struct. InternalBufferCapacity allocated to almost max out chunk memory.
GhostSpawnClassificationSystem
The default GhostSpawnClassificationSystem will set the SpawnType to the default specified in the GhostAuthoringComponent, unless some other classification has already set the SpawnType. This system will also check ghost owner to set the spawn type correctly for owner predicted ghosts. For predictive spawning you usually add a system after GhostSpawnClassificationSystem which only looks at items with SpawnType set to Predicted and set the PredictedSpawnEntity if you find a matching entity. The reason to put predictive spawn systems after the default is so the owner predicted logic has run.
GhostSpawnQueue
GhostSPawnQueue is used to identify the singleton component which contains the GhostSpawnBuffer.
GhostSpawnQueueComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
GhostSpawnSystem
System responsible for spawning all the ghost entities for the client world.
When a ghost snapshot is received from the server, the Ghost
Based on the spawning (Ghost
When the mode is set to Interpolated, the ghost creation is delayed
until the Interpolation
When the mode is set to Predicted, a new ghost instance in spawned immediately if the
current simulated Server
Otherwise, the ghost creation is delayed until the the Server
GhostType
Component storing the guid of the prefab the ghost was created from. This is used to lookup ghost type in a robust way which works even if two ghosts have the same archetype
GhostTypeComponent
Temporary type for upgradability, to be removed before 1.0
GhostTypePartition
Component used on the server to make sure the ghosts of different ghost types are in different chunks, even if they have the same archetype (regardless of component data).
GhostUpdateSystem
System present only in client worlds, and responsible for:
- updating the state of interpolated ghosts, by copying and intepolating data from the received snapshosts.
- restore the predicted ghost state from the Ghost
- updating the Predicted
HostMigrationConfig
Configuration that can be tune the behaviour of certain internal systems within the host migration feature.
HostMigrationInProgress
This component will be present for the duration of a host migration. It can be used when certain systems or operations should run or not run according to host migration state.
HostMigrationStats
Statistics for a running host migration system on the host.
IPCAndSocketDriverConstructor
The default NetCode driver constructor, initialise the server world to use multiple Unity.
- On the server: both Unity.
Networking. and Unity.Transport. IPCNetwork Interface Networking. NetworkDriver in the editor and only a single Unity.Transport. UDPNetwork Interface Networking. driver in the build.Transport. UDPNetwork Interface - On the client:
- a single Unity.
Networking. NetworkDriver if the both client and server worlds are present in the same process.Transport. IPCNetwork Interface - a single Unity.
Networking. driver in all other cases.Transport. UDPNetwork Interface
In the Editor and Development build, if the network simulator is enabled, force on the client to use the Unity.Networking. network driver. To let the client use the IPC network interface when in client and server mode, you must create the server world first (in other words; callTransport. UDPNetwork Interface NetworkStreamDriver.Listen
on it before attempting to connect to it).
- a single Unity.
IncomingCommandDataStreamBuffer
This buffer stores a single incoming command packet. One per NetworkStream (client). A command packet contains commands for CommandSendSystem.k_InputBufferSendSize (default 4) ticks where 3 of them are delta compressed. It also contains some timestamps etc for ping calculations.
IncomingCommandDataStreamBufferComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
IncomingRpcDataStreamBuffer
One per NetworkConnection. Stores queued, incoming RPC data. Thus, buffer size is related to inbound-from-server RPC count * size. InternalBufferCapacity is zero as RPCs can vary in size, and we don't want to constantly move the RPC data into and out of the chunk.
IncomingRpcDataStreamBufferComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
IncomingSnapshotDataStreamBuffer
One per NetworkConnection.
Stores the incoming, yet-to-be-processed snapshot stream data for a connection.
Each snapshot is designed to fit inside Unity.
IncomingSnapshotDataStreamBufferComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
InputBufferData<T>
The underlying ICommand
InputEvent
This type can be used inside IInput
IsReconnected
This tag is added to connections and ghost entities when they are reconnected or respawned.
MigrationTicket
Am singleton entity returned by the Store
NetCodeConnectionEvent
Contains a single, discrete 'NetworkConnection' connect / disconnect event.
For more details, refer to Connection
NetCodeDebugConfig
Add this component to a singleton entity to configure the NetCode package logging level and to enable/disable packet dumps.
NetDebug
Singleton handling NetCode logging and log management.
NetDebugSystem
Systems responsible to initialize and create the Net
NetworkDriverStore
Store and manage an array of NetworkDriver. The capacity is fixed to Capacity. The driver registration should start by calling BeginDriverRegistration() and terminate with EndDriverRegistration(). The store also provide some accessor and utlilty methods.
NetworkDriverStore.Concurrent
Struct that contains a the Unity.
NetworkDriverStore.NetworkDriverInstance
Struct that contains a Unity.
NetworkGroupCommandBufferSystem.Singleton
Call Get
NetworkId
The connection identifier assigned by the server to the incoming client connection. The NetworkIdComponent is used as temporary client identifier for the current session. When a client disconnects, its network id can be reused by the server, and assigned to a new, incoming connection (on a a "first come, first serve" basis). Thus, there is no guarantee that a disconnecting client will receive the same network id once reconnected. As such, the network identifier should never be used to persist - and then retrieve - information for a given client/player.
NetworkIdComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
NetworkMetrics
Singleton component for Network and Time Related Metrics.
NetworkProtocolVersion
The NetworkProtocolVersion is a singleton entity that is automatically created by the
Ghost
The protocol version is composed by different part:
- The NetCode package version.
- A user defined Game
- A unique hash of all the IRpc
- A unique hash of all the replicated IComponent
When a client tries to connect to the server, as part of the initial handshake, they exchange their protocol version to validate they are both using same version. If the version mismatch, the connection is forcibly closed.
NetworkSnapshotAck
Client and Server Component. One per NetworkId entity, stores SnapshotAck and Ping info for a client.
NetworkSnapshotAckComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
NetworkStreamConnectSystem
A system processing NetworkStreamRequestConnect components
NetworkStreamConnection
A connection is represented by an entity having a NetworkStreamConnection.
The component hold a reference to the underlying transport Unity.
- Outgoing
Client connections also have a Incoming
NetworkStreamDriver
Singleton that can hold a reference to the Network
NetworkStreamInGame
A component used to signal that a connection should send and receive snapshots and commands. Before adding this component the connection only processes RPCs. Must be Added by game logic to start sending snapshots and commands.
NetworkStreamListenSystem
A system processing NetworkStreamRequestListen components
NetworkStreamReceiveSystem
The NetworkStreamReceiveSystem is one of the most important system of the NetCode package and its fundamental job
is to manage all the Network
- creating the Network
- handling the driver migration (see Driver
- listening and accepting incoming connections (server).
- exchanging the Network
- updating the Connection
NetworkStreamRequestConnect
A component that can be added to a new entity to create a new connection instead of calling Connect(Entity
NetworkStreamRequestDisconnect
A component used to signal that the game logic wants to close the connection
NetworkStreamRequestListen
A component that can be added to a new entity to start listening to a new connection instead of calling Listen(Network
NetworkStreamRequestListenResult
Optional cleanup component that can be added to the Network
NetworkStreamSnapshotTargetSize
A per-connection component, which is used by the Ghost
NetworkTick
A simple struct used to represent a network tick. This is using a uint internally, but it has special logic to deal with invalid ticks, and it handles wrap around correctly.
NetworkTime
Present on both client and server world, singleton component that contains all the timing characterist of the client/server simulation loop.
NetworkTimeSystem
System responsible for estimating the Server
The system tries to keep the server tick (present on the client) ahead of the server, such that input commands (see ICommand
This time synchronization start taking place as soon as the first snapshot is received by the client. Because of that,
until the client Network
In the case where the client and server world are on the same process, and an IPC connection is used (see IPC), some special optimizations can be applied. E.g. In this case the client should always run 1 tick per frame (server and client update in tandem).
NetworkTimeSystemData
Stores the internal state of the NetworkTimeSystem. The component should be used for pure inspection or backup the data. Please don't change the the state values direclty.
OutgoingCommandDataStreamBuffer
This buffer stores a single outgoing command packet without the headers for timestamps and ping. A command packet contains commands for CommandSendSystem.k_InputBufferSendSize (default 4) ticks where 3 of them are delta compressed. It also contains some timestamps etc for ping calculations.
OutgoingCommandDataStreamBufferComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
OutgoingRpcDataStreamBuffer
One per NetworkConnection. Stores queued, outgoing RPC data. Thus, buffer size is related to client-authored RPC count * size. InternalBufferCapacity is zero as RPCs can vary in size, and we don't want to constantly move the RPC data into and out of the chunk.
OutgoingRpcDataStreamBufferComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
PendingSpawnPlaceholder
Component on the client signaling that an entity is a placeholder for a "not yet spawned" ghost. I.e. Not yet a "real" ghost.
PendingSpawnPlaceholderComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
PortableFunctionPointer<T>
Simple RAII-like wrapper that simplify making C# function delegate burst compatible.
PositionOnlyVariant
A serialization strategy for Unity.
PositionRotationVariant
A serialization strategy that replicates the entity Unity.
PositionScaleVariant
A serialization strategy that replicates the entity Unity.
PreSerializedGhost
Adding this component to a ghost will trigger pre-serialization for that ghost. Pre-serialization means that part of the serialization process happens before the regular serialization pass and can be done once for all connections. This can save some CPU time if the the ghost will generally be sent to more than one player every frame and it contains complex serialization (serialized data on child entities or buffers).
PreSpawnedGhostIndex
Unique within a subscene and used to deterministically assign ghost id to pre-spawned ghost entities.
PredictedGhost
Component on client signaling that an entity is predicted (as opposed to interpolated).
PredictedGhostComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
PredictedGhostSpawn
Added to a Predicted
PredictedGhostSpawnList
Tag added to the singleton entity that contains the Predicted
PredictedGhostSpawnRequest
Optional component, used to request predictive spawn of a ghosts by the client. The component is automatically added to the authored ghost prefabs when:
- The baking target is Client or Client
The predicted spawn request is consumed by Predicted
The package provides a default handling for predictive spawning (Default
PredictedGhostSpawnRequestComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
PredictedGhostSpawnSystem
Consume all the Predicted
PredictionErrorMetrics
Monitor prediction errors of ghosts.
PredictionErrorNames
A list of all currently available Prediction Error names.
This list maps 1-1 with Prediction
PredictionSwitchingSmoothing
Optional component that can be added either on a per entity or on per-chunk basis that allow
to customise the transition time when converting from predicted to interpolated Ghost
PrefabDebugName
The name of ghost prefab. Used for debugging purpose to pretty print ghost names. Available only once the NETCODE_DEBUG define is set.
PrespawnSectionAck
Component added by the server to to the NetworkStream entity. Used to track witch prespawned ghost sections has been loaded/acked by the client. The server streams prespawned ghost only for the sections that as been notified ready by the client.
PrioChunk
Structure that contains the ghost Archetype
ReceiveRpcCommandRequest
A component used to signal that an RPC has been received from a remote connection and should be processed.
ReceiveRpcCommandRequestComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
RelevantGhostForConnection
A connection-ghost pair, used to populate the Ghost
RotationOnlyVariant
A serialization strategy for Unity.
RotationScaleVariant
A serialization strategy that replicates the entity Unity.
RpcCollection
The RpcCollection is the set of all available RPCs. It is created by the RpcSystem. It is used to register RPCs and to get queues for sending RPCs. In most cases you do not need to use it directly, the generated code will use it to setup the RPC components.
RpcCommandRequest<TActionSerializer, TActionRequest>
Helper struct for implementing systems to process RPC command request entities. This is generally used by code-gen, and should only be used directly in special cases.
RpcCommandRequest<TActionSerializer, TActionRequest>.SendRpcData
A struct that can be embedded into your system job, and should be used to delegate the rpc handling. Example of use:
[BurstCompile]
struct SendRpc : IJobChunk
{
public RpcCommandRequest{MyRpcCommand, MyRpcCommand}.SendRpcData data;
public void Execute(in ArchetypeChunk chunk, int unfilteredChunkIndex, bool useEnabledMask, in v128 chunkEnabledMask)
{
data.Execute(chunk, unfilteredChunkIndex);
}
}
Always use the Init
RpcDeserializerState
Interop struct used to pass additional data to the Deserialize(ref Data
RpcExecutor
Struct that can be used to simplify writing systems and jobs that deserialize and execute received rpc commands.
RpcExecutor.Parameters
Struct used as argument to the rpc execute method (see the Rpc
RpcQueue<TActionSerializer, TActionRequest>
A helper struct that should be used schedule outgoing RPCs.
The RpcQueue is used internally by the code-generated systems that consume the
Send
You can use the RpcQueue in your custom system by retrieving an instance for the given
TActionRequest
, TActionSerializer
pair from the Rpc
RpcSerializerState
Interop struct used to pass additional data to the Serialize(ref Data
RpcSystem
The system responsible for sending and receiving RPCs.
The RpcSystem flushes all the outgoing RPCs scheduled in the Outgoing
Because packet queue size is limited (Unity.
When an rpc packet is received, it is first handled by the Network
RpcSystemErrors
A system responsible for handling all the Rpc
The connection that generated the Rpc
- The local protocol.
- The remote protocol.
- The list of all registered rpc.
- The list of all registered serializer.
SendRpcCommandRequest
A component used to signal that an RPC is supposed to be sent to a remote connection and should not be processed.
SendRpcCommandRequestComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
ServerPopulatePrespawnedGhostsSystem
Responsible for assigning a unique ghost
ServerTrackLoadedPrespawnSections
The ServerTrackLoadedPrespawnSections is responsible for tracking when an initialized prespawn sections is unloaded in order to release any allocated data and freeing ghost id ranges.
SharedGhostTypeComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
SimulatorPreset
Presets for the com.unity.transport simulator. Allows developers to simulate a variety of network conditions.
SnapshotData
Component present only for ghosts spawned by the client, tracking the latest Snapshot
SnapshotData.DataAtTick
Internal use only.
SnapshotDataBuffer
A data structure used to store ghosts snapshot buffers data content. Typically around 1-12kb per entity. Thus, we always allocate on the heap.
SnapshotDynamicBuffersHelper
Helper class for managing ghost buffers data. Internal use only.
SnapshotDynamicDataBuffer
A data structure used to store ghosts dynamic buffers data content. BeginArray(SnapshotHistorySize] uint dataSize, (16 bytes aligned) current serialized data length for each slot. Used for delta compression EndArray BeginArray(SnapshotHistorySize] for each buffers: uint[maskBits] elements change bitmask byte[numElements] serialized buffers data EndArray The buffer grow in size as necessary to accomodate new data. All slots have the same size, usually larger than the data size. The serialized element size is aligned to the 16 bytes boundary
SnapshotMetrics
Snapshot metrics singleton component.
SnapshotPacketLossStatistics
Stores packet loss causes and statistics for all received snapshots. Thus, client-only (with one exception).
Access via Network
SpawnedGhost
Struct used to uniquely identify a ghost given its id and spawning time.
SpawnedGhostEntityMap
Singleton entity used store the entities references for all the spawned ghost.
SubSceneGhostComponentHash
The hash of all the ghost component data which exists in the scene. This can be used to sort the subscenes so the ghost IDs of the pre-spawned scene objects line up deterministically.
SubSceneWithPrespawnGhosts
Added during conversion to all subscenes that contains pre-spawned ghosts.
SwitchPredictionSmoothing
A struct that is temporarily added to a ghosts entity when it switching between predicted / interpolated mode.
Added by Ghost
SwitchPredictionSmoothingSystem
System that manage the prediction transition for all ghost that present a Switch
The system applying a visual smoohting to the ghost, by modifying the entity Unity.
TransformDefaultVariant
The default serialization strategy for the Unity.
UniqueInputTickMap
This singleton is used by code-gen. It stores a mapping of which ticks the client has changes to inputs so steps in the prediction loop can be batched when inputs are not changing.
UnscaledClientTime
Component added to the NetworkTime singleton entity when it is created in a client world. Contains the unscaled application ElapsedTime and DeltaTime.
WarnAboutApplicationRunInBackground
If you disable runProject Settings... Player... Resolution and Presentation... Run In Background
.
WarnAboutBatchedTicksSystem
WarnAboutStaleRpcSystem
Interfaces
IApprovalRpcCommand
An interface which can be used to implement RPCs for use in the connection approval flow.
Only IApproval
Connection approval can be optionally required for all incoming connection on a server. The connection flow
can only proceed when the server received an Approval RPC payload which it can validate.
Approval tokens are game-specific, thus netcode expects user-code to add an Connection
ICommandData
Commands (usually inputs) that must be sent from client to server to control an entity (or any other thing) should implement the ICommandData interface.
Prefer using the ICommandData over Rpc if you need to send a constant stream of data from client to server, as it's optimized for this use-case.
Prefer to keep this type as small as possible, as it scales exponentially with player count and tickrate.
ICommandData, being a subclass of IBuffer
However, differently from a normal GhostComponent, ICommandData buffers are not replicated from the server to all clients by default. Instead, in the absence of a GhostComponentAttribute governing the serialization behavior, the following set of default rules are used:
- Prefab
- Send
- Owner
Is generally not recommended to send back to the ghost owner its own commands. For that reason, setting the
Send
- Server: While possible, does not make much sense. A warning will be reported.
- Clients: The ICommandData buffer is stripped from the server ghost. A warning will be reported.
- InterpolatedClient: ICommandData buffers are stripped from the server and predicted ghost. A warning will be reported.
- Predicted: ICommandData buffers are stripped from the server and predicted ghost. A warning will be reported.
- AllPredicted: Interpolated ghost will not have the command buffer.
- All: All ghost will have the command buffer.
ICommandDataSerializer<T>
Interface that must be implemented to serialize/deserialize ICommand
IGhostComponentSerializerRegistration
For internal use only.
The interface for all the code-generated ISystems responsible for registering all the generated component
serializers into the Ghost
IGhostSerializer
Interface that expose a raw, unsafe interface to copy all the component ghost fields to the snapshot buffer. It is mostly for internal use by code-gen and should not be used direcly nor implemented by user code.
IGhostSerializer<TComponent, TSnapshot>
Interface implemented by all the component/buffer serialiser. For internal use only.
IInputBufferData
Interface used to handle automatic input command data setup with the IInputComponentData style inputs. This is used internally by code generation, don't use this directly.
IInputComponentData
A special component data interface used for storing player inputs.
IInputEventHelper<T>
Internal use only, interface implemented by code-generated helpers to increment and decrement
IInput
INetworkStreamDriverConstructor
Factory interface that needs to be implemented by a concrete class for creating and registering new Unity.
IRpcCommand
An interface that should be used to declare a Rpc struct.
RPCs are "one-shot" messages that can be sent and received by both the client and server, and can be used for different
purposes. E.g. Implementing a lobby, loading level logic, requesting to spawn a player etc.
Unlike ghost Snapshot
As they're reliable messages, RPCs are not meant to be used as a replacement for ghosts, nor for sending data that will change frequently,
nor player commands (ICommand
An RPC struct can contain any number of burst-compatible fields. However, once serialized, its size must fit into a single packet. Large messages are not supported (NetworkParameterConstants.MaxMessageSize and account for header sizes).
It is possible to partially mitigate this limitation by creating a custom INetwork
Usage: To send an RPC declared using the IRpc
m_RpcArchetype = EntityManager.CreateArchetype(..);
var ent = EntityManager.CreateEntity(m_RpcArchetype);
EntityManager.SetComponentData(new MyRpc );
RPCs declared using the IRpc
public struct MyRpc : IRpcCommand
{
public int SomeData;
}
will generate the following systems and structs:
- A struct implementing the IRpc
- A system responsible for consuming the Send
Because the serialization is generated by our source generator, only types recognized by the code-generation system
(and that are available to use inside commands and rpcs) are going to be serialized.
See Type
The Outgoing
To distinguish between a "broadcast" RPC and an "RPC sent to a specific client", see Send
IRpcCommandSerializer<T>
Interface that must be implemented by a burst-compatible struct to serialize/deserialize the
specified T
type.
A common pattern is to make the struct declaring the rpc to also implement the serialize/deserialize interface. For example:
struct MyRpc : IComponentData, IRpcCommandSerializer{MyRpc}
{
public void Serialize(ref DataStreamWriter writer, in RpcSerializerState state, in MyRpc data)
{ ... }
public void Deserialize(ref DataStreamReader reader, in RpcDeserializerState state, ref MyRpc data)
{ ... }
PortableFunctionPointer{RpcExecutor.ExecuteDelegate} CompileExecute()
{ ... }
}
When declaring an rpc using the IRpc
Enums
ClientServerBootstrap.PlayType
The current modality.
ClientServerTickRate.FrameRateMode
Enum to control how the simulation should deal with running at a higher frame rate than simulation rate.
ComponentTypeSerializationStrategy.DefaultType
Denotes why this strategy is the default (or not). Higher value = more important.
ConnectionState.State
The current state of the connection.
DataStorageMethod
How the host migration data is serialized for sending to the service.
GhostCollectionPrefab.LoadingState
Ghost prefabs can be added dynamically to the ghost collection as soon as they are loaded from either a
sub-scene, or created dynamically at runtime.
This enum is used on the clients, to signal the ghost collection system that the Ghost
GhostMode
The Current Ghost Mode of a Ghost, on any given client. Denotes replication and prediction rules.
GhostModeMask
Stores the Supported Ghost Mode
by a ghost at authoring time.
GhostOptimizationMode
Specify if the ghost replication should be optimized for frequent (dynamic) or for infrequent (static) data changes.
GhostPrefabCreation.ComponentOverrideType
Identifier for a type of modifier, the types can be combined using "or" and serves as a mask.
GhostPrefabType
Assign to every GhostGhostAuthoringInspectionComponent
to manually override on a specific Ghost prefab.
GhostRelevancyMode
Specify how the ghosts added to the relevancy set should be used.
GhostSendType
An optimization: Set on each GhostComponent via the Ghost
When a Ghost is Owner
Maps to the Ghost
Note that this optimization is not available to Ghosts that can have their Ghost
GhostSpawnBuffer.Type
The ghost mode to use to spawn th entity
NetCodeConfig.AutomaticBootstrapSetting
Client
NetDebug.LogLevelType
The available NetCode logging levels. Notify is the default. Use the
Net
NetworkStreamDisconnectReason
Reasons for a Unity.
NetworkStreamProtocol
The message types sent by NetCode.
NetworkStreamRequestListenResult.State
The status of the listen request./
NetworkTimeFlags
Flags used by Network
PredictionLoopUpdateMode
Configure when the prediction loop should run on the client.
SendToOwnerType
Meta-data of a ICommand
See the documentation for ICommandData:ICommand
SimulatorView
For the PlayMode Tools Window.
SmoothingAction
Denotes how Ghost
TransportType
The transport category/type use by a NetworkDriver.
Delegates
AutomaticThinClientWorldsUtility.ThinClientWorldInitializationDelegate
Delegate for Default
GhostImportance.BatchScaleImportanceDelegate
Scale importance delegate. This describes the interface Ghost
GhostImportance.ScaleImportanceDelegate
Scale importance delegate. This describes the interface Ghost
GhostPredictionSmoothing.SmoothingActionDelegate
All the smoothing action must have this signature. The smoothing actions must also be burst compatible.
GhostPrefabCustomSerializer.ChunkPreserializeDelegate
Delegate for the custom chunk pre-serialization function.
GhostPrefabCustomSerializer.ChunkSerializerDelegate
Delegate for the custom chunk serializer.
GhostPrefabCustomSerializer.CollectComponentDelegate
Delegate to specify a custom order for the serialised components.
NetworkDriverStore.DriverVisitor
Signature for all functions that can be used to visit the registered drivers in the store using the For
RpcExecutor.ExecuteDelegate
The reference to static burst-compatible method that is invoked when an rpc has been received. For example:
[BurstCompile(DisableDirectCall = true)]
[AOT.MonoPInvokeCallback(typeof(RpcExecutor.ExecuteDelegate))]
private static void InvokeExecute(ref RpcExecutor.Parameters parameters)