- Home /
Multiplayer - networking without network view?
Hi all!
I am creating a procedural game (procedural/infinite terrain). No problem so far in single player. The terrain is chunk based, only a few chunks around the player are displayed of course, when getting far away from a chunk, it is getting destroyed and a new one is created.
The problems I have are limitation with network views. At least to my knowledge.
All child object of a terrain chunk (trees, rocks, enemies,...) and the chunk itself are destroyed when the chunk is far away from player. But: if another player is still on that chunk, he will send networkViews update to all players. But as others do not have those object any-more in their game, errors pop-up as those networkViewsIDs were removed from their game instance.
Thus I wonder how I could manage networking this type of game.
Should I completely stop using network views? But then how to communicate objects/players/enemies updates?
Should I use only one master network view for all network updates? Using rather complex RPCs from that network view to update all object/player/enemy manually. In that case I could maybe filter incoming RPCs to check if the update received concerns an object present on 'my' game instance. Or even find a way to send from the server updates only to players that will need it.
I know that this question might be rather complex, and of course I am not asking for a code to do it, just a reflection on how you guys would try to solve this case.
Hoping my English was good enough and that I was clear! Thank you all for your help
Answer by Anxo · Oct 28, 2014 at 03:37 PM
Sounds more like a logic problem than an issue with the network view component. Are you sending RPC calls to destroy the objects? If so you need to make sure RPC mode is set to server to avoid sending a message to all the players. RPCMode.Server. But why would one player ever want to destroy terrain in another players instance? Maybe when the player does something like mining where you destroy the terrain but just walking away from it should not destroy it for other players right? Keep as much local as you can. Now should you as far as the error is concerned, just check if the object you are trying to access is null before you access it.
Thanks for your answer.
Yes, I do send RPC to destroy objects when needed (like when an object is 'killed')
Players do not destroy terrain (chunks) on other players instances. We agree on that :)
$$anonymous$$y problem is for example when player A cuts down a tree. I need players that have the tree loaded on their game receive update on that tree 'health'. But how can I send that information only to the players having that tree? Some players are too far away and don't even see that tree, so do not need to constantly receive its updates. Currently, the network view on that tree synchronizes the health status of that tree. But players not having that tree loaded receive an error as their instance of the game do not have that tree's network view loaded.
Sorry, I feel that I am still not verry clear...
Basicly, all networkViewIDs are not present all the time for all players. Isn't that a problem in Unity? From what I understand all networkViews need to be loaded all the time for all players. Is that correct?
oh haha, well I would not put a network view on the tree that is not universal for all. The idea of the network view is that this is a component that all need to see. You could try having an object that manages trees which gets updated. So if a player gets to a location where a tree was cut down, the "Tree$$anonymous$$ananger" has that information , the tree manager is always updated, and exists on every instance, so even if people leave that spot and go back to it, the tree manager can tell another players $$anonymous$$m manager that this particular tree was already cut down when he gets there and generates it.
Thanks, I see what you mean, ill try to do that, with just one 'master' network view to send RPCs to update trees.
But then, how would I work with GO needed to be updated 'constantly'? Tree was a simple example, but same thing applies to all my GOs. For my enemies, controlled by the server, should I then send an RPC on every Update (function) while they are moving/attacking? Isn't that a too heavy on network bandwidth?
How do they do those things in games like $$anonymous$$ecraft, cubeworld, or any other huge procedurally created games? Or at least, how would I do that in Unity?
Thanks again!