Skip to content

0.3.0-preview.3

Pre-release
Pre-release

Choose a tag to compare

@marwie marwie released this 21 Aug 14:05

[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 GhostField and GhostComponent attributes 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.
  • Code gen support for RPCs, an RPC can be created without writing serialization by hand. Implement the IRpcCommand interface and write it like you would a regular IComponentData - the serialization code will be generated for you.
  • GhostGroups are now supported. A ghost prefab can have a GhostGroup buffer 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 the GhostChildEntityComponent component added to it. The GhostChildEntityComponent can be added at runtime when moving the child entity into the group.
  • Relevancy support has been added. By changing GhostSendSystem.GhostRelevancyMode to GhostRelevancyMode.SetIsRelevant or GhostRelevancyMode.SetIsIrrelevant on the server and adding ghosts to GhostSendSystem.GhostRelevancySet you 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 NetworkStreamSnapshotTargetSize which is used to control the target size for snapshots.
  • Added GhostReceiveSystem.GhostCountOnServer and GhostReceiveSystem.GhostCountOnClient which can be used to check how many ghosts a client should have and how many it does have.

Changes

  • Support for NativeString64 has been replaced by support for FixedString64. Support for FixedString32, FixedString128, FixedString512 and FixedString4096 has 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 DisableLagCompensationComponent which 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

  • NativeString64 is no longer uspported, change your code to use FixedString64 instead.
  • GhostUpdateSystemGroup no longer exists, references to it for update order should be replaced with GhostUpdateSystem
  • 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 GhostField attributes to the component since manual overrides are no longer supported.
  • For all ghosts which removes a component from Server, Interpolated Client or Predicted Client you 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, Importance and Default ghost mode are still correct. Supported Ghost Mode and Optimization Mode are 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 GhostOwnerComponent and make sure your code sets the NetworkId of that component correctly. Previously you could store the network id in any component and point the GhostAuthoringComponent to 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 either GhostSendType.Interpolated or GhostSendType.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 PredictedGhostSpawnRequestComponent to the entity.
  • Any custom spawn behavior - including matching entities for pre-spawned ghosts - previously implemented in MarkPredictedGhosts must be moved to a spawn classification system.
  • Any custom code to modify spawned ghosts previously implemented in UpdateNewPredictedEntities or UpdateNewInterpolatedEntities must be moved to systems running in the GhostSpawnSystemGroup after GhostSpawnSystem. Use tag components to deterct which ghosts are new.

RPC

  • If your IRpcCommand component only uses RpcExecutor.ExecuteCreateRequestComponent in the execute method you can remove the implementations for Serialize, Deserialize, CompileExecute along with the execute method and burst function pointer for it. You also need to remove the CommandRequestSystem implementationf 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 of public stuct MyRequest : IRpcCommand.
  • The signature for RPC serialization has changed to void Serialize(ref DataStreamWriter writer, in MyRequest data) and deserialization has changed to void Deserialize(ref DataStreamReader reader, ref MyRequest data).
  • The CommandRequestSystem for rpcs with manual serialization/execute must be changed from class MyRequestCommandRequestSystem : RpcCommandRequestSystem<MyRequest> to class MyRequestCommandRequestSystem : RpcCommandRequestSystem<MyRequest, MyRequest>