Hi.
I am working on a simple 2 player multiplayer game, which is based on the gameplay of marble madness.
The game works as it should, except for one thing, which is really making me mad right now.
Problem:
Whenever other network applications send or receive some data over the network / internet, my game gets stuck for some milliseconds.
This also happens when I start the game twice on local machine and play it with myself!
Example:
We are playing my game (or I play it twice on local machine) and someone sends me a message on Steam.
When this happens, the game (or both games on local machine) will complety freeze for some milliseconds (micro-lag).
(with freezing I mean: not responding at all, no FPS, no inputs - but just a really short time)
Debugging:
I am not sure how to Debug this behaviour, because at the moment it happens, nothing gets executed.
The only thing I can say is: my game stops at random position in script execution.
I have tried several Debug-Messages within each script so I could see at which point it stops.
But it seems to depend on the other network applicationm, because it is never the same place where it freezes.
And as I said before, the game runs smooth when no other applications use the network.
We can play the game over internet without lag at all.
But as soon as the network is used, it will freeze for some very short time.
PC specs / network / unity:
- CPU: Core i7 @ 3,0 GHz (8 cores)
- GPU: GTX 580 with 3 GB VRAM
- RAM: 16 GB DDR3 @ 1600 MHz
- Network: Cable 100 MBit/s, average ping below 20 ms
- Unity (free) 4.5.5f1
Networking / RPCs:
- I have two player-controlled spheres (marbles), which get spawned with ‘Network.Instantiate()’
- Each of them uses a ‘playerMove.cs’ Script which will check for User inputs ‘Input.GetAxis()’
- Each of them has a ‘NetworkView’ attached (Off, not monitoring - using RPCs instead!)
- Each of them has a ‘NetworkManager.cs’ Script, which sends / receives RPCs depending on ownership.
The RPCs are called within ‘Update()’ and send the Transform.position, Transform.rotation and Rigidbody.velocity of the Player-Spheres. (RPCMode.Others)
This works fine and without lag, as long as there is no other network application actively sending/receiving data.
One message on steam is enough to let the game freeze for a short time.
Questions:
- How I can start to Debug/Find the problem?
- Did anyone here experience the same problem before? (And were you able to you solve it? How?)
At the moment my RPCs are send each time, when ‘Update()’ is executed, because the Player-Spheres
are moving most of the time (even when there is no UserInput, because they are still rolling).
I just started to use Unity Networking and I am not sure if it is okay to send so many RPCs without limitations.
So the question is: Do I send to many RPCs and could this be part of the problem?
I hope I could explain the problem and the current game enviroment to make it all clear for you.
I am still learning and this could be a noob-question/problem… let me know. =)
Edit - 28. Nov: Seems to be local PC problem, not related to networking.
A new and empty project with only one moving sphere and no networking also lags,
when something gets display in my taskbar (tooltips, blinking messages / windows).