Hello guys, I am developing a online game and everything is working fine, players can use skills, level up, chat, etc. (check my facebook page for videos about the game: Redirecting...).
The Problem:
My map is getting bigger and bigger, right now I have 240.000 tiles and the server is loosing a lot of performance. The profiler says the problem is NetworkServer.UpdateServerObjects(), this method is a loop through all my server objects and all NetworkBehaviours. So far I am using NetworkProximityChecker to Spawn on client-side, only tiles that are close to the Player.
The Question:
What I did, is the best way to implement a UNET Open World Tile Map and I need just buy a better server machine or there are better method to implement this design?
You should enable only objects that are in close proximity to player. One way how to achieve this is via NetworkProximityChecker.
Or you can implement your own solution that AI, players, objects, tiles wont be enabled unless player is in their range.
There dont have to be camp with bandits on other side of map if player cannot see or interact with them.
Yes, definitely ensure that the server only sends info on relevant (and close) things to each connected client. Clients don’t need to know about stuff that’s far away.
I have each of my objects keep it’s own list of connected clients within range, and whether they’ve just entered range (spawn), are still in range (update), or have left range (despawn) of the object. More work for the server to do to keep these range lists, but a massively smaller load on the networking system.
1 Like
The way you guys suggested, are already developed and working, the server only send data to close players, I have my own custom NetworkProximityChecker and it’s have better performance than unity’s (I can choose layers, interval, range, etc). The server are loosing performance due a loop inside NetworkServer class, this loop, runs over all networked objects on server and I do not have control over this loop, it’s made by Unity and the lack of control is the problem.
Is really this approach you guys suggested or I misunderstood you?
Sounds like your Proximity code is similar to mine (which is cool - means we both came to the same conclusions).
As for NetworkServer class - I found it had way to much junk in there pertaining to the control of objects, and other game related stuff that wasn’t of any use to me; so I chose to use NetworkServerSimple instead - It is a stripped down version that does all the network traffic handling, but has no game stuff, enabling me to write my own.
I glad to hear that, about Proximity!
So, about this NetworkServerSimple, you have to call NetworkServerSimple.Update() manually to pull the incoming data, am I correct? If I am correct, maybe this is what I have to use, to gain the control that I need.
Yes, you need to poke it manually with Update() which isn’t a bad thing. Certainly it’s event based messaging has enabled me to tailor handlers to exactly what I want without any of the other rubbish that NetworkServer does (which is great for some types of game; just not mine).
OK, I think you led me to the right direction here, I hope I don’t need to change my entire game to achieve that.
Thank you , I will try to use NetworkServerSimple.