Networked Fog-of-war Possible with Network.Instaniate?

Working on a project where each player can see their own units in detail and only limited or no detail of their opponents units. Essentially a fog-of-war.

The server has all ‘real’ GameObject units on it. It also has the fog-of-war view of each player - opponents units are represented by stand-in GOs that contain less information than the ‘real’ GO. So, with 2 players, there are 4 hierarchies:
RedTeam Units
BlueTeam Units
RedTeam’s View of other units
BlueTeam’s View of other units.

I am playing ‘hotseat’ right now where I can press a button to change render views to see from Red or Blue perspective using Render Layers to limit drawing.

How (if at all) would I use Network.Instantiate to do the same thing on multiple clients, given that it instantiates and syncs on all clients? I want Red Player to see only RedTeamUnits and RedTeamView. Obviously I could just limit visibility like I do in hotseat, but if at all possible I don’t even want to send data about BlueTeam and BlueTeamView to the Red client.

If this is not possible with Network.Instantiate, how else do you do it? More specifically, how do you send specific sync states to a subset of clients?

BTW, this is a fairly slow paced game so FPS level of network performance may not be crucial.

You are right that Network.Instantiate is not going to work very well. Also, if you can only see the units you are supposed to see, then something has to decide that. That sounds an awful lot like an authoritative server which sends updates based upon visibility.

Exactly. I currently have the code working for determining visibility on the server. Just not sure how to send one set of data to one client and different set of data to another client. I’m sure this is pretty basic.

Maybe roll my own Network.Instantiate that broadcasts ‘create instance’ RPCs to all clients but have a client ignore it if it is not relevant.

networkView.RPC("SpawnUnit", RPCMode.All, viewID, transform.position, (int)ESide.RED);
void SpawnUnit(NetworkViewID viewID, Vector3 location, int side) {
  if (side != (int)player.mySide) return;
 ...

But then how do I send sync data only to those clients that have this particular Red unit?

That authoritative server would have to check visibility and then give the right players the updates. If the object disappears from view, then it should also be told to the players that cannot see it that it has disappeared from view in which case they will no longer display it. Maybe just toggle it as invisible/inactive locally until it is updated again as being active/visible or explicitly destroyed.

Thanks. I guess my question is regarding this:

How do you tell one player different information than you tell to other players? Is it something like this:
Server sends RPC to all players that unit RedA is no longer visible to player Blue.

  • all players except Blue receive but ignore this message
  • Blue sets a flag on it’s local copy of RedA that it is invisible (or just destroys it’s local copy of RedA?)

Server continues sending RedA OnSerializeNetworkView data to all players,

  • Blue ignore updates to RedA if local invisible is true

a follow-up - if RedA is never Instantiated on the Blue client, what happens to OnSerializeNetworkView for RedA sent to client Blue? Is there an error or is it just ignored?

We are trying to do a similar thing, so if anyone has good ideas on the best way to approach this sort of thing it would be great to know.

I guess it really comes down to implementing everything with custom networking, you can’t use network instantiate, you can’t use views etc.

Network.Instantiate has very limited use, if you instantiate and uninstatiate these objects it will be fine as long as nobody reconnects. If you plan to let players join a game in progress, you need to minimize the use of instantiate.

Can SetScope or network group be used in some way to achieve this player filtering?

Does set scope get called in the server code and then prevent that data being sent to the specific player?
http://unity3d.com/support/documentation/ScriptReference/NetworkView.SetScope.html

they can
just keep in mind that setscope only works with OnSerializeNetworkView not with RPCs

Also, instantiate naturally can not make use of it.

Can I ask how network views fit into these situations?