First player camera activates fine but the second camera

Lethn
Lethn
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Photon;

public class RoomManager : Photon.MonoBehaviour

{
    public GameObject spawnPoint;
    public GameObject spawnButtonEmpty;
    public GameObject spawnMenuCamera;
    FirstPersonController firstPersonController;

    public GameObject player;

    public void SpawnPlayer()

    {

        GameObject localPlayer = PhotonNetwork.Instantiate(player.name, spawnPoint.transform.position, Quaternion.identity, 0);
        spawnButtonEmpty.SetActive(false);
        spawnMenuCamera.SetActive(false);
        Cursor.lockState = CursorLockMode.Locked;
        Cursor.visible = false;
        localPlayer.transform.Find("PlayerCamera").gameObject.SetActive(true);
        Debug.Log("Local Player Camera Activated");
        firstPersonController = localPlayer.GetComponent<FirstPersonController>();
        firstPersonController.enabled = true;
    }
}

I'm really getting along now with PUN code which is nice, once you wrap your head around the weird quirks of networking it's becoming quite nice to use. I've run into another quirk however that I can't quite figure out, when I spawn my first player into the game over the network, the camera activates exactly as shown in the code below. However despite me going through the exact same process with the second player the camera doesn't activate.

Does anyone have any idea why this is?

Comments

  • Lethn
    Lethn
    edited March 2019
    Bumping, would be nice to get an answer on this problem.

    Update:

    Just to say, I ended up investigating this more and it looks like it's not the camera itself that's the problem but the camera is not being shown with it's children. So what I mean by that is, even though the camera and my gun attached to it is enabled, the other player can't see the gun being activated.

    Is this related to PUN somehow not showing the activated gameobjects over the network? Because on the first person view everything is activated fine.
  • Bump