- Home /
Decreasing FPS (Network)
Hi there!
I've noticed that my fps becomes much lower as a new players connect. So i've decided to to try Deactevate player (and creatures) gameObjects wich are Far from MY networkView. But i can't figure out how to reach this. So throw me an idea, please!
Answer by fuego_see_money · Jun 30, 2015 at 05:58 PM
Is the camera fairly static? 2D game? 3D game? For 2D games what I have done in the past is check and see if other players are visible in my viewport, and if they arent, ignore them. However this brings issues when a player runs quickly into your viewport, so what you should really do is check a little bit outside of the visible range of the camera, as well.
Lets say this is your viewport:
P5
__________
| |
| P1 | P4
| P2 |P3
|__________|
Obviously you should track player 2. Some would argue to only track player 2...but player 3 is so close to you to the point that by the time his position is updated to your computer, he could have shot you already, and it would look like no one shot you on your screen. So you should really track players 3 and 2, and ignore 4 and 5 until they get closer. Your algorithm should do this, essentially:
P5 ________________
| __________ |
| | | |
| | P1 | | P4
| | P2 |P3|
| |__________| |
|________________|
where the middle box is your actual viewport, and the outer box is where you still continue to update other players.
Thank's for your reply! $$anonymous$$y problem is in RPC's wich players send. When i hide players wich are far away from me, i can't track their position anymore as they send their position by RPC but they dont exist for me. So i can't figure out how to know how to activate these player's again when they come closer.
Hmm...I see what you mean. I have an idea though -
Using my previous example, you should change the way you update your enemy players based on how far away they are.
For P2, send and receive all data needed (position, rotation, animations, etc).
For P3, send and receive only position updates, because since he isn't visible, rotation and animations are not needed.
For P4 and P5, only send position updates once a second (or something like that). That way, you can still track when they get close to your viewport, and when they get close, begin to treat them as you did P3. And when they actually enter your viewport, treat them as P2.
Hope this helps, -Will
I've understood! It's pretty simple and it is exactly what i need:) Thank you, Will!