After upgrading my game world which is now containing 150k trees (network instantiated) and 600 NPC’s I sometimes get network delay spikes. Which feels like if messages get paused and saved up until eventually (after 2-3 seconds) it get’s released to the client.
The trees don’t do much serialization, they just spawn with some information regarding grow percentage. And the NPC’s only get like 1 update every so second.
I have reversed the proximity checker to work for a player > object base instead of every tree checking if there are players near. So I did some optimizing already.
The thing is I really don’t know how to tackle those random spikes as we are only talking 10-15 players online.
What is the best option for me to debug this?
Are there any network settings I have to alter to reduce the lag? Cause I’m not using the network manager but instead use this to start my server:
Personally I use all the defaults. Except my channels and all of that ofcourse. But all the in depth stuff such as disconnect timeouts etc I have so far had no reason to edit for my title.
I am mainly focusing on developing the game and the network code atm. Haven’t dug to deep into that as of yet.
I use Reliable Non sequenced for Game State.
Unreliable Sequenced for Movement.
Reliable Fragmentet for Text Chat
And a second Unreliable Sequenced for VoiceChat
Unreliable. Cause, I send movement updates at 20hz maximum. And at I don’t care if I loose a packet or two. Reliable basically resends the same packet over and over until you get a response. That’s just not needed.
And sequenced I use to prevent rubber band if they come in the wrong order. You could implement this yourself but UNET channels does it neatly by discarding the packets.
i agree with what twoten said, you might want to just have one network’d object for all your trees, and it can be smarter about syncing the data for your trees. like unless the client can see all 150k trees at the same time, you could cook up something that only updates the trees in the area the client is looking, etc.
same with the NPCs - if there’s some way you can batch them up, it will be much easier to conserve bandwidth.
especially if you’re using sync vars…actually i wouldn’t use sync vars at all for a project of that scale.
That said, if you make a gane where you click to move around. You are better off syncing the clicks rather than the position. And that would be done reliably. It’s all about how you perform your game.
In addition, our game uses Server Authortive movement for the most part. (We have some other tricks to make our workflow easier).
Exactly, so if you need some “Update” loop running on the trees. What you could technicly do is have the Manager object have a global Update loop, That is a coroutine that spreads the work of updating all trees across frames. So that every tree only gets a update ran every x frames for example.
I will give this a thought for sure!
Btw, do you know if SyncVar updates too all clients or just observers? Cause if the proximity is not working it’s probably a LOT of messages thats causing the problem.