PhotonView.isMine is broken.
Options
Hi. I've been making a game for my portfolio that I can use for my college interview, and for the past month or so making my game with photon has been great. Until today, everything was running smoothly, until isMine broke down completely. Here's the simple task that uses isMine:
using UnityEngine; public class PlayerNetwork : Photon.MonoBehaviour { [Header("Properties")] public PlayerMove playerMove; public Rigidbody2D rb; public GameObject Aim; public PhotonNetworkManager pnm; public Transform eyes; public PlayerMove move; [Header("Network Properties")] public bool OfflineMode; // Use this for initialization void Start () { Initialize(); } public void Initialize() { if (!OfflineMode) { if (!photonView.isMine) { playerMove.enabled = false; //playermove is, well, what lets us move Aim.SetActive(false); //aim is what lets us aim rb.isKinematic = true; //setting our rigidbody to kinematic to avoid any nonsense with the rigidbody } } pnm = GameObject.Find("GameLogic").GetComponent<PhotonNetworkManager>(); } }Incredibly simple. However when I play my game, both of my characters move when I use my arrow keys. So what's going on?
0
Answers
-
I see this is a bit older but I believe its similar to another issue I answered today.
I can't quite follow the logic as you are using allot of public set variables. However what I believe is happening is. You are not really setting the player controls to a disabled state the way you think.
**--Sorry major edit as I had a major brain fart on this one.
Try removing the components entirely from the player prefab that !isMine.
The following is straight from the tutorial.private void Awake() { if (!photonView.IsMine && GetComponent<Player>() != null) { Destroy(GetComponent<Player>()); } }
Yours might look like the below code. Might have to play with it.private void Awake() { if (!photonView.IsMine && playerMove != null) { Destroy(playerMove); } if (!photonView.IsMine && Aim!= null) { Destroy(Aim); } }
0