FPS Camera dont work with Network

Hello there, i am making an FPS game and i am prity new. I found out that the camera is wierd and this is what happend. When i start a server and an other person connect i get the newst camera (His view) and he get an other (My view). I have also tested this with many connections and i see that the first get the newest one and the secund connection get the next newest one and so on...

I looked around on the forum and found some codes, but now its turn all black as if there was no camera...

The code i found was this:

function Update()
{
    if(networkView.isMine)
    {
        //find all cams and disable 
        allCams = FindObjectsOfType(Camera); 
        for (var cam : Camera in allCams) 
        { 
            cam.enabled = false; 
        } 
        //turn on own cam 
        var myCamO = this.gameObject;
        var myCam = myCamO.camera;
        myCam.enabled = true; 
    }
}

1 Answer

1

get rid of your new code and turn the all cameras off by default. then when your level or player loads turn on the correct camera locally. Had the same problem myself.

camera.enabled = true; also check out http://unity3d.com/support/documentation/ScriptReference/Camera.html