Esempio n. 1
0
    public void SpawnNetworkedPlayer(Vector3 pos, Quaternion rot, PhotonViewID id1, PhotonPlayer np)
    {
        Transform newPlayer = Instantiate(tankPrefab, pos, rot) as Transform;
        //Set the PhotonView
        PhotonView[] nViews = newPlayer.GetComponentsInChildren<PhotonView>();
        nViews[0].viewID = id1;

        // Name the gameObject for cleanliness
        newPlayer.gameObject.name = np.name;

        // Set tank mode
        if (np.isLocal)
        {
            playerTank = newPlayer.gameObject;
            playerScript = newPlayer.GetComponent<Tank>();
            playerScript.SetTankType(Tank.TankMode.LocalPlayer);
            cameraManager.orbit = newPlayer.gameObject.transform;
        }
        else
        {
            newPlayer.GetComponent<Tank>().SetTankType(Tank.TankMode.RemotePlayer);
        }
    }