Netcode Object Visbility compatibility with Object Pooling

I have been looking for more way to lower the bandwidth of network transform component. One of which is Object Visibility, meaning the server will do the calculation then decide which objects other clients can see. It works great on non pool network object but cause serveral issue when use with pool network object. Mainly because of how invinsible object will get destroy or despawn on client, that will mess with how network object pool spawn and despawn object to keep it in the pool.

Are there some ways to work around this issue? Any help would be much appreciated.

Im using Unity 6000.0.34f1, Unity Transport 2.4.0, NGO 2.20

What‘s responsible for most of the bandwidth? Did you tweak the settings available ie in NetworkTransform. If you rely on Network* components chances are you can lower your traffic by a factor of 5 or more just by implementing the synchronization yourself, and especially when doing so in a batch operation (ie all enemies in a single message/rpc, and ideally sending a packed and compressed byte array.

May be easier to implement and reap greater benefits.

Thanks for replying.
So my character is a 2d ragdoll, with 5 nested network transform, 4 players max per section. So network transform takes up most of the bandwidth.

Furthermore, only the player use client network transform, other objects use Smooth Sync on the asset store to lower the bandwidth.

Can u suggest me any place to start with writing my own synchronization? And did i correct about Object Visibility not working with Object pooling?

That is not the purpose of Smooth Sync, at best it’s a welcome side effect but it isn’t a network bandwidth optimization asset.

What does the NetworkTransform transfer? Do you have all checkboxes ticked?

In a 2D ragdoll you really only need to synchronize the following data:

  • position XY + rotation angle (if any) of the root “bone”
  • the relative (local) angle of each child in relation to the root respectively its parent (eg hand-arm-body)

You can probably compress the angles to “half” types (16 bit). But you really don’t need to send the whole quaternion if that’s what you do.

I only send xy position and z rotation, and yes i did use half precision whenever i could. Unfortunately, sending only xy position of the root bone aka the body in my game is not enough, hands and legs are connect using hinge joint and both have xy local position change slightly ranging from -0.8 to 0.8. But not syncing them will cause issue

I also did a rough estimate, each player transform will send 64 byte, 64 × 4 players + at least 80 byte for other network transform.

If you have implemented a NetworkObject pool properly where you are registering an INetworkPrefabInstanceHandler implementation with the NetworkManager.PrefabHandle, then when the Destroy method is invoked you should just be able to disable the instance and place it back into the pool.

You can see an example here: ObjectPoolSystem.cs

Regarding tweaking NetworkTransform, you might look at your threshold values to determine if the default threshold is too low. The default for position is to send an update when there is a +/- 0.001 delta…which depending on the world scale you are using could be very low. If you are using interpolation you might be able to get away with something like 0.01 or even 0.1.

The final tweak you could do is just dynamically update the threshold on the authority side (i.e. who sends delta state updates) based on the linear or angular velocity… the faster an object is moving he higher the threshold (i.e. if your object is moving at like 50 unity world space units per second you really don’t need to send every 0.001 delta…more like every 1.0 delta or higher…and likewise if it drops down to like 0.5 to 0.01 Unity world space units per second then you might have it drop down to 0.001 in order to get more precise deltas).

The general idea is adjusting axis threshold based on how fast or slow something is moving/rotating.

1 Like