- Home /
Trees make my network game lag?
I'm making a FPS multiplayer networked game just for fun, and I wanted to put a forest in the level. That worked fine, but now when I run it and there's lot of trees around, the network starts to lag horribly. My computer is definitely up to the task, and it plays perfectly in the editor, but when I start to use the network in the build version, the trees make it almost unplayable. Any ideas?
Answer by Owen-Reynolds · Jan 18, 2012 at 01:50 AM
Are you using "network spawn" to make the trees? If so, that's a lot of data being sent each frame (position/rotation/scale for each tree.)
As long as they are spawned in the same places, the trees probably don't need to be continuously synched up between clients -- each client can Instantiate them normally. To get the same locations, have the server pick spots and send to everyone using something like (from memory) NetworkView.RPC("spawnTree", x, z, RPC.All);
. SpawnTree instantiates at x,z and height(x,z).
I added the trees to a terrain using a brush, so they shouldn't be syncing to the server, right?
Ah. The Terrain->PlaceTrees button? If your terrain doesn't have a networkView, (and why would it) there's no way they should be able to be sending any data. Still, checking Stats/Network would tell you if it really is a network problem, or something incidental.
Only other suggestion is to jack up all the tree distance/max sliders in single-player, to check it isn't simply a problem with too many trees (if you're running both players on the same machine.)
Right, so I think I figured it out. Whenever I play it full screen, the framerate drops like a rock, but if I use the same settings with the game in a window, it plays just fine. $$anonymous$$ust be something with Unity or my graphics card, so I'll try to figure it out.
Your answer
Follow this Question
Related Questions
Trees greatly reduces FPS 1 Answer
Unity Network Transform delay 1 Answer
Reduce Lag (trees) 1 Answer
Unity 5.2 Unet, extreme Lags after updating from 5.1 1 Answer