0.3.0-preview.3
Pre-release
Pre-release
[0.3.0-preview.3] - 2020-08-21
New features
- New workflow for generating serialization code for ghosts. In the new workflow code is generated per component and there is no codegen per ghost type prefab.
- The ghost fields and ghost components are now configured in code with
GhostFieldandGhostComponentattributes where you can configure parameters for prediction, interpolation, quantization and so on. - The ghost component and collection inspectors now only show you how the ghosts have been configured in code.
- Ghosts can now be generated on demand and you don't need to explicitly push a button to do it.
- A new ghost compiler windows allows you to change how the generation is handled, like changing from on demand generation to manual) and shows you if any ghost is out of sync.
- The ghost fields and ghost components are now configured in code with
- Code gen support for RPCs, an RPC can be created without writing serialization by hand. Implement the
IRpcCommandinterface and write it like you would a regularIComponentData- the serialization code will be generated for you. - GhostGroups are now supported. A ghost prefab can have a
GhostGroupbuffer added to it at authoring time, all ghosts listed in that buffer are guaranteed to be sent together with the main entity. In order to be in a group the child ghost must have theGhostChildEntityComponentcomponent added to it. TheGhostChildEntityComponentcan be added at runtime when moving the child entity into the group. - Relevancy support has been added. By changing
GhostSendSystem.GhostRelevancyModetoGhostRelevancyMode.SetIsRelevantorGhostRelevancyMode.SetIsIrrelevanton the server and adding ghosts toGhostSendSystem.GhostRelevancySetyou can limit the set of ghosts which are sent to a specific client. - Added an optimization mode to ghosts, the new static optimization mode will use less aggressive delta compression which allows us to stop sending data completely when no entities in a chunk have been modified.
- Added visualization of prediction errors to the NetDbg.
- A connection entity on the server can have a
NetworkStreamSnapshotTargetSizewhich is used to control the target size for snapshots. - Added
GhostReceiveSystem.GhostCountOnServerandGhostReceiveSystem.GhostCountOnClientwhich can be used to check how many ghosts a client should have and how many it does have.
Changes
- Support for
NativeString64has been replaced by support forFixedString64. Support forFixedString32,FixedString128,FixedString512andFixedString4096has also been added. - In dynamic timestep mode it is now possible to resume prediction from the last full predicted tick instead of rolling back to the latest received snapshot when no new data has been received.
- Added a
DisableLagCompensationComponentwhich when added as a singleton prevents the lag compensation system from running.
Fixes
- Quaternions are renormalized after dequantization to make sure they are still valid rotations.
- Floats are rounded to the nearest int after quantization to improve acuracy.
- It is now possible to send more than one packet with RPC commands per frame, previously commands could be silently dropped when doing that.
Upgrade guide
NativeString64is no longer uspported, change your code to useFixedString64instead.GhostUpdateSystemGroupno longer exists, references to it for update order should be replaced withGhostUpdateSystem- NetCode now requires Unity 2020.1.2.
New ghost workflow
- Change all
[GhostDefaultField]to[GhostField]and all[GhostDefaultComponent]to[GhostComponent]in your components. The parameters to the constructors have also changed, you need to specify[GhostField(Quantization=100, Interpolate=true)]instead of[GhostDefaultField(100, true)]. - For all ghosts which manually adds fields you must add
GhostFieldattributes to the component since manual overrides are no longer supported. - For all ghosts which removes a component from
Server,Interpolated ClientorPredicted Clientyou must add a[GhostComponent(PrefabType=<type>)]attribute to the component where<type>matches what you had before. - For all components which you do not want to synchronize when they are on child entities of a ghost you need to add
[GhostComponent(SendDataForChildEntity = false)]. - Open all prefabs and verify that
Name,ImportanceandDefault ghost modeare still correct.Supported Ghost ModeandOptimization Modeare new fields and the default values matches what the old workflow did. - For all ghosts which uses the owner predicted mode you must add a
GhostOwnerComponentand make sure your code sets theNetworkIdof that component correctly. Previously you could store the network id in any component and point theGhostAuthoringComponentto it. - For all components which you were only being sent to either interpolated or predicted ghosts when used on owner predicted ghosts you need to add
[GhostComponent(OwnerPredictedSendType = <type>)]where<type>is eitherGhostSendType.InterpolatedorGhostSendType.Predicted. - Delete the generated code from the old NetCode version.
- If you are using predictive spawning the new way to request a predictive spawn is to instantiate the predicted client version of the ghost prefab and add a
PredictedGhostSpawnRequestComponentto the entity. - Any custom spawn behavior - including matching entities for pre-spawned ghosts - previously implemented in
MarkPredictedGhostsmust be moved to a spawn classification system. - Any custom code to modify spawned ghosts previously implemented in
UpdateNewPredictedEntitiesorUpdateNewInterpolatedEntitiesmust be moved to systems running in theGhostSpawnSystemGroupafterGhostSpawnSystem. Use tag components to deterct which ghosts are new.
RPC
- If your
IRpcCommandcomponent only usesRpcExecutor.ExecuteCreateRequestComponentin the execute method you can remove the implementations forSerialize,Deserialize,CompileExecutealong with the execute method and burst function pointer for it. You also need to remove theCommandRequestSystemimplementationf for your component. All of those will be generated by code-gen. - All RPC implementations which still needs manual serialization or execute must be changed to implement
public struct MyRequest : IComponentData, IRpcCommandSerializer<MyRequest>instead ofpublic stuct MyRequest : IRpcCommand. - The signature for RPC serialization has changed to
void Serialize(ref DataStreamWriter writer, in MyRequest data)and deserialization has changed tovoid Deserialize(ref DataStreamReader reader, ref MyRequest data). - The CommandRequestSystem for rpcs with manual serialization/execute must be changed from
class MyRequestCommandRequestSystem : RpcCommandRequestSystem<MyRequest>toclass MyRequestCommandRequestSystem : RpcCommandRequestSystem<MyRequest, MyRequest>