Player Prefab tutorial

(I copied this from another thread, this seems like a better place for it)
Hi there. I'm trying to go through the tutorials, using the update that just dropped, and I'm getting a null reference exception when trying to check if(photonView.IsMine). I assumed I made a typo or something, so tried using the included PlayerManager.cs file instead, same error on awake, line 67. I was trying to maybe use PhotonNetwork.GetPhotonView() to assign it a value, but I can't because it's read only, and I don't know which view to get anyway.

Halp?

Comments

  • JonBrantJonBrant
    edited September 4
    Oh, I also had to make the script in the tutorial inherit from MonoBehaviourPunCallbacks to get photonView to show up. Not sure if that's an issue
    That was the next step
  • JonBrantJonBrant
    edited September 4
    Ok, I was able to get past this by changing the contents of Update() to
    if (PhotonView.Get(this).IsMine) { ProcessInputs(); } else { if (PhotonNetwork.IsConnected) { Debug.Log("Transfering ownership to you!"); PhotonView.Get(this).TransferOwnership(0); } else { Debug.Log("Not my photonView! Can't transfer because !PhotonNetwork.IsConnected"); } } if (beams != null && isFiring != beams.activeSelf) { beams.SetActive(isFiring); }

    This only works if you're connected, so I used the buttons we created in the previous sections to get connected and it seems to be working. But I now realize that this will just assign every photonView to one player.... so I need a proper fix


    Well, continuing with the tutorial got me sorted out, but being told to hit play and see it working when getting errors is clearly pretty confusing lol.
Sign In or Register to comment.