Namespace Unity.NetCode
Classes
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.
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 to configure and create the Server and Client worlds at runtime when
the game start (in the editor when entering PlayMode).
The ClientServerBootstrap is meant to be a base class for your own custom boostrap code and provides utility methods
that make it easy creating the client and server worlds.
It also support connecting the client to 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
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
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.
FixedStepGhostPredictionSystemGroup
Temporary type for upgradability, to be removed before 1.0
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.
GhostGhostComponentAttribute
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 gather systems. Only present in client worlds,
it runs before the Command
GhostPredictionSystemGroup
Temporary type for upgradability, to be removed before 1.0
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. 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
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
NetCodePhysicsConfig
Component used to enable predicted physics automatic world changing(Predicted
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
PhysicsDefaultVariantSystem
Optionally register the default variant to use for the Unity.Physics.PhysicsVelocity and the
Unity.Physics.GraphicsIntegration.PhysicsGraphicalSmoothing.
PhysicsVelocity
nor the PhysicsGraphicalSmoothing
components
if they are already present in the Default
Any system deriving from Default
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.
PredictedPhysicsConfigSystem
A system which setup physics for prediction. It will move the PhysicsSystemGroup to the PredictedFixedStepSimulationSystemGroup.
PredictedSimulationSystemGroup
The parent group for all "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
Importantly: Because the client is predicting ahead of the server, all systems in this group will be updated multiple times
per simulation frame, every single time the client receives a new snapshot (see Network
These re-simulation prediction group ticks also get more frequent at higher pings.
I.e. Simplified: A 200ms client will likely re-simulate roughly x2 more frames than a 100ms connection, with caveats.
And note: The number of predicted, re-simulated frames can easily reach double digits. Thus, systems in this group
must be exceptionally fast, and are likely your CPU "hot path".
To help mitigate this, take a look at prediction group batching here Max
Pragmatically: This group contains most of the game simulation (or, at least, all simulation that should be "predicted" (i.e. simulation that is the same on both client and server)). On the server, all prediction logic is treated as authoritative game state (although thankfully it only needs to be simulated once, as it's authoritative).
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
SwitchPredictionSmoothingPhysicsOrderingSystem
System to make sure prediction switching smoothing happens after physics motion smoothing and overwrites the results
TransformDefaultVariantSystem
System that optinally 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:
- Local
Transform - Unity.Transforms.Translation
- Unity.Transforms.Rotation
It will never override the default assignment for the transform components if they are already present in the Default Variants map.
Any system deriving from Default
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
It is not mandatory to set all the fields to a proper value when creating the singleton. It is sufficient to change only the relevant setting, and call the Resolve
- the maximum number of tick per frame
- the maximum number of tick per frame
- tick batching (Max
Simulation and others.Step Batch Size
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
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 Auto
- you want to support thin-clients (because Auto
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
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.
EnablePacketLogging
Add this component to connection entities NetworkDebug
level) in general or to enable ghost snapshot or packet logging per connection.
Debug information can be toggled globally in the Playmode Tools Window and in the NetCodeDebugConfigAuthoring
component.
GameProtocolVersion
The game specific version to use for protcol 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
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.
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
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.
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
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.
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.
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 base ghost importance can be set at authoring time on the prefab (Ghost
- age (the last time the entities has been sent)
- scaled by distance, (see Ghost
- scaled by custom scaling (see Ghost
The send system can also be configured to send multiple ghost packets per frame and to to use snaphost larger than a single MTU.
In that case, the snapshot packet is sent using another unreliable channel, setup with a Fragmentation
GhostSendSystemData
Singleton entity that contains all the tweakable settings for the Ghost
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
IPCAndSocketDriverConstructor
The default NetCode driver constructor, initialise the server world to use multiple Unity.
- On the server: both IPCNetwork
Interface and UDPNetworkInterface NetworkDriver in the editor and only a single UDPNetworkInterface driver in the build. - On the client:
- a single IPCNetwork
Interface NetworkDriver if the both client and server worlds are present in the same process. - a single UDPNetwork
Interface driver in all other cases.
In the Editor and Development build, if the network simulator is enabled, force on the client to use the UDPNetworkInterface network driver.
- a single IPCNetwork
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 MTU, so expect this to be MTU or less.
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
LagCompensationConfig
Singleton entity that allow to configure the NetCode LagCompensation system. If the singleton does not exist the PhysicsWorldHistory system will not run. If you want to use PhysicsWorldHistory in a prediction system the config must exist in both client and server worlds, but in the client world HistorySize can be different from the server - usually 1 is enough on the client.
MigrationTicket
Am singleton entity returned by the Store
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.NetworkDriverInstance
Struct that contains a Network
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
NetworkProtocolVersion
The NetworkProtocolVersion is a singleton entity that is automatically created by the Network
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
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 Network
- Outgoing
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
PhysicsGraphicalSmoothingDefaultVariant
Default serialization variant for the PhysicsGraphicalSmoothing which disables smoothing on interpolated clients. Ghost are controled by the server rather than physics on interpolated clients, which makes the physics smoothing incorrect.
PhysicsVelocityDefaultVariant
Default serialization variant for the PhysicsVelocity. Necessary to synchronize physics
PhysicsWorldHistory
A system used to store old state of the physics world for lag compensation. This system creates a PhysicsWorldHistorySingleton and from that you can get a physics collision world for a previous tick.
PhysicsWorldHistorySingleton
A singleton component from which you can get a physics collision world for a previous tick.
PortableFunctionPointer<T>
Simple RAII-like wrapper that simplify making C# function delegate burst compatible.
PositionOnlyVariant
A serialization strategy for Local
PositionRotationVariant
A serialization strategy that replicates the entity Position and Rotation properties.
PositionScaleVariant
A serialization strategy that replicates the entity Position and Scale properties.
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).
Ghost
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
And .Server - When using the hybrid authoring workflow, if the GhostAuthoringComponent.SuypportedGhostModes is Predicted or All.
- When using the Convert
To , if the SupportedGhost Prefab(Entity Manager, Entity, Config, Native Parallel Hash Map<Component, Component Override>) Ghost is set to Predicted or All. The predicted spawn request is consumed by PredictedModes Ghost , which will remove the component from the instantiated entity after an initial setup.Spawn System
The package provides a default handling for predictive spawning (DefaultGhost ). In case you need a custom or more accurate way to match the predicted spawned entities with the authoritive server spawned ones, you can implement a custom spawn classification system. See GhostSpawn Classification System Spawn for further details.Classification System
PredictedGhostSpawnRequestComponent
Temporary type, used to upgrade to new component type, to be removed before final 1.0
PredictedGhostSpawnSystem
Consume all the Predicted
PredictedPhysicsNonGhostWorld
If a singleton of this type exists in the world any non-ghost with dynamic physics in the default physics world on the client will be moved to the indicated physics world index. This is required because the predicted physics loop cannot process objects which are not rolled back.
PredictedPhysicsValidationSystem
A system used to detect invalid dynamic physics objects in the predicted physics world on clients. This system also moves entities to the correct world if PredictedPhysicsNonGhostWorld exists and is not 0.
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.
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 Local
RotationScaleVariant
A serialization strategy that replicates the entity Rotation and Scale properties.
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
TActionRequest
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 (Send
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.
Append
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
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 Local
TransformDefaultVariant
The default serialization strategy for the Local
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.
Interfaces
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
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 Network
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.MTU 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 { SomeData = 5 });
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
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 IRpcEnums
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.
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.
Stores the `Supported Ghost Mode` by a ghost at authoring time.
- Interpolated:
- Predicted: Predicted Ghosts are predicted by the clients. I.e. Their Simulate component is enabled during the
execution of the Predicted
- All: Predicted Ghosts are predicted by the clients. I.e. Their Simulate component is enabled during the
execution of the Predicted
GhostModeMask
Stores the `Supported Ghost Mode` by a ghost at authoring time.
- Interpolated:
- Predicted: Predicted Ghosts are predicted by the clients. I.e. Their Simulate component is enabled during the
execution of the Predicted
- All: Predicted Ghosts are predicted by the clients. I.e. Their Simulate component is enabled during the
execution of the Predicted
GhostOptimizationMode
Specify if the ghost replication should be optimized for frequent (dynamic) or for infrequent (static) data changes.
`Static` optimization mode is designed for ghosts that will change infrequently (i.e. rarely, or not change at all).In this mode the ghost is replicated to the client only when its state changes, which can bring good bandwidth savings, but it comes at the cost of additional cpu cycles to perform change-checking. As such, static optimization should be avoided for entities that frequently change their state, since it will actually increase both bandwidth (because of the extra protocol bits necessary) and cpu cost.
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
NetDebug.LogLevelType
The available NetCode logging levels. Notify is the default. Use the
Net
NetworkStreamDisconnectReason
NetworkStreamProtocol
The message types sent by NetCode.
NetworkStreamRequestListenResult.State
The status of the listen request./
NetworkTimeFlags
Flags used by Network
SendToOwnerType
Meta-data of a ICommand
Docs for 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
SmoothingAction
Denotes how Ghost
TransportType
The transport category/type use by a NetworkDriver.
Delegates
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.
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)