Hi there,
hm… someone suggested to remove all unnecessary stuff from the server. That was a very cool idea
I had disabled all cameras on the server, so the minimum FPS I got when “going really crazy” (switching on the smoke and shooting as fast as I could hit the X-key in TRaceON) was 115 FPS (average in normal gameplay is about 900 FPS). Notably, on my Mac Pro with the game running on the same machine as the server (I didn’t really have time to test this in a cleaner setting with separate machines right now). When I have the cameras switched on, on the server, I’m getting it down to 30 FPS. Here, average in “normal game play” is 300 FPS.
So, today after being a bit frustrated with creating a rock-solid “seems-like-lag-free” networking even with 0.3 or 0.4s lag (by having both client and server in the editor both with networking emulation set to dial-up) - I’m not finished with that, yet - I decided to write a little magic script:
The call to DisableMe() from the Update is just to be super-safe and should actually never be called… but you never know… and if it’s called, it’s only called once
I attached this script to each and every game object that’s not relevant for the gameplay-logic. I only needed to “refactor” one prefab, because I made the mistake of putting colliders and scripts on the same game object on which I also had the particles (don’t do that, when you’re planning to do networking ).
Well, that was all done in one quick hour… And now guess what: No matter how hard I try, I can’t get the FPS below 950, no matter what I try (and the game goes down to 15 FPS in these “harsh conditions”).
Now, when I use this optimization, even when I leave the camera switched on on the server (which is quite useful for testing), I’m still struggling to get the server FPS below 700…
Feel free to use this “little trick” - it might save you some headaches… All you need is some “NetworkManager” script that you attach to some game object in your first scene and that you use with the “Unity singleton pattern” (DontDestroyOnLoad but do destroy when multiple instances are created)…
The numbers above were with server and one client on the same machine. I just did another test with 4 clients + 1 server on my Mac Pro. The worst FPS I get on the server is still 300 FPS. I think that’s really nice… Can’t wait to test this on the “real server” with 20 players (I still need to find 20 players, though )
Ahhhh - now all the frustration is gone
Sunny regards,
Jashan