Network problem (NetworkView)

Hello,

I’m making a fps game (http://fragzone.p.ht/fragzone/). It’s solo for now, but I plan to make it multiplayer.

I followed the tutorial on Unity Cookie, but I can’t understand the whole thing.

I don’t know how and why to put NetworkView, nor I know what to desactivate with the “networkView.isMine”.

I need help, thank you for reading !

Re,

I confirm I have read http://docs.unity3d.com/Documentation/Components/net-NetworkView.html but it’s to technically speaking, It’s not clear for me.

I have tried to do

But it has a strange behaviour. Plus the two instanciated character does not see each other…

Any help ?

Read it again untill you understand then, networking is very technical.

Yeah you’re right. But it’s hard to understand without example application.

Finally I followed a tutorial and came to a better (working) piece of script :

However even is Player is enable all my characters move at the same time.

Any idea ?

You have to consider that most parts of networking objects players are not automated on the remote side.

If for example say you create a player prefab that tracks player movement, fire gun input and mouse look controls then creating this object on both sides client and server will have a player GameObject that will read in input given from the player. If a client joins your game and his / her player GameObject is being created on your local game it’s is also going to have the same MouseLook and other user Input based controls enabled. So even the remote objects are going to try to obey your User Input. Plus if they have a Camera object attached they will try to take over that or may try finding the main camera to highjack.

Knowing this you’ll need to understand how prefab’s should be adapted on the remote side so they won’t be controlled locally.

See some changes given below…
[I don’t know what should or should not be enabled in your example but I took a guess]

#pragma strict

function Awake()
{
// This is a Remote Game Object so don't track user input ...
if (!networkView.isMine)
 {
   GetComponent(Player).enabled = true;
   GetComponent(FPSInputController).enabled = false;
   GetComponent(MouseLook).enabled = false;
   GetComponentInChildren(Shoot).enabled = true;
   GetComponentInChildren(Camera).enabled = false;
 }

So knowing this you’ll find reading the docs more helpful. Sometimes you want things to only occur on the server like Network.isServer or the client Network.isClient. Eventually it will all make sense.