Improbable Icon

Bandwidth optimizations

I am doing client-predicted player movement (following: https://www.codersblock.org/blog/client-side-prediction-in-unity-2018), and it is required to send input keys from Client to Server, and then send location, rotation, speed, angularVelocity from Server to client.

So I created a schema for the Server-to-client part: (the client-to-server part is fine due to small size of message)

component Verifiedpos{
   id = 1075;
   float x=1;
   float y=2;
   float z=3;

   float speedx=4;
   float speedy=5;
   float speedz=6;

    uint32 ticknumber=7;

   float eulerx=8;
   float eulery=9;
   float eulerz=10;
   
   float angularspeedx=11;
   float angularspeedy=12;
   float angularspeedz=13;

}

As you can see, the network usage by above update( 10 update per sec) is HUGE. I wonder if

  1. How Can i use smaller types like uint8 (4 bytes) in schemalang? Uint8 isnt included in https://documentation.improbable.io/sdks-and-data/docs/schemalang-reference#section-primitive-types
  2. What would be the most efficient way of sending update, e.g. via events or updates?
  3. What would be the best practice for client-prediction & server-authoritative movement? (in terms of bandwith performance)
    Thanks

Hello @Henry-Lee

Have you tried using the Transform Synchronization module? https://documentation.improbable.io/gdk-for-unity/docs/transform-synchronization

Tansform sync is not what I want. I need server authority.

You can use the transform sync component with the server being authoritative over it. The usage would be similar to what you described above (send input keys from Client to Server, and then send location, rotation, speed from Server to client).

If you still want to use your own system, you can the way the Transform sync module represents a transform and use it as a base to your own - https://documentation.improbable.io/gdk-for-unity/docs/how-it-works

as for the other questions

  1. The most effective way would be via the position component update

  2. There’s no silver bullet for this one. You’ll first need to test your game in “real life” environments and then you’ll have a starting point to understand what you need exactly.

Thanks, i am trying out that, but Transform sync is not working after following https://documentation.improbable.io/gdk-for-unity/docs/transform-synchronization.

When I play and move the player, the player restores to original position immediately. Is there some setting that i can use to specify this authoritative player is the ‘sender’ of transform sync?

@JaySantos

NullReferenceException: Object reference not set to an instance of an object
Improbable.Gdk.TransformSynchronization.TransformSynchronization.OnEnable () (at Library/PackageCache/io.improbable.gdk.transformsynchronization@0.3.8/MonoBehaviours/TransformSynchronization.cs:60)
UnityEngine.Object:Instantiate(GameObject, Vector3, Quaternion)
Improbable.Gdk.GameObjectCreation.GameObjectCreatorFromMetadata:OnEntityCreated(SpatialOSEntityInfo, GameObject, EntityManager, EntityGameObjectLinker) (at Library/PackageCache/io.improbable.gdk.gameobjectcreation@0.3.8/GameObjectCreatorFromMetadata.cs:43)
Improbable.Gdk.GameObjectCreation.GameObjectInitializationSystem:b__12_0(Entity, SpatialEntityId&, Component&) (at Library/PackageCache/io.improbable.gdk.gameobjectcreation@0.3.8/GameObjectInitializationSystem.cs:183)
Unity.Entities.EntityQueryBuilder:ForEach(F_EDD`2) (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/EntityQueryBuilder_ForEach.gen.cs:416)
Improbable.Gdk.GameObjectCreation.GameObjectInitializationSystem:ProcessNewEntities() (at Library/PackageCache/io.improbable.gdk.gameobjectcreation@0.3.8/GameObjectInitializationSystem.cs:152)
Improbable.Gdk.GameObjectCreation.GameObjectInitializationSystem:OnUpdate() (at Library/PackageCache/io.improbable.gdk.gameobjectcreation@0.3.8/GameObjectInitializationSystem.cs:122)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
Unity.Entities.ComponentSystemGroup:UpdateAllSystems() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:134)
Unity.Entities.ComponentSystemGroup:OnUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystemGroup.cs:114)
Unity.Entities.ComponentSystem:Update() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ComponentSystem.cs:108)
Unity.Entities.DummyDelegateWrapper:TriggerUpdate() (at Library/PackageCache/com.unity.entities@0.9.1-preview.15/Unity.Entities/ScriptBehaviourUpdateOrder.cs:200)