photonView.isMine Isn't Working!

Hello. In my script, I am trying to make it so that if the player is mine, make him a yellow dot on the minimap, and if its not mine, make it a green dot. When I first spawn my player, hes a yellow dot. When I add another player, they are both suddenly green dots. What am I doing wrong? Both dots are attached to the player on top of him and this script is also attached to the player:
[code2=csharp]using UnityEngine;
using System.Collections;

public class WhichMinimapDotColor : Photon.MonoBehaviour {

// Use this for initialization
void Start () {


}

// Update is called once per frame
void Update () {
GameObject greendot = GameObject.Find("GreenMinimapDot");
GameObject yellowdot = GameObject.Find("YellowMinimapDot");
if(photonView.isMine)
{
greendot.transform.renderer.enabled = false;
yellowdot.transform.renderer.enabled = true;
}
else if(!photonView.isMine)
{
greendot.transform.renderer.enabled = true;
yellowdot.transform.renderer.enabled = false;
}
}
}[/code2]
Thanks in advance! :)

Comments

  • If you don't use "PhotonNetwork.Instantiate" to create the objects, isMine is apparently always true (at least in my experience anyway)... I'm guessing that's what's wrong.
  • As Ace points out: How are you spawning the gameobject / how is the photonview added?
  • Hello. Thanks for replying! So I do use PhotonNetwork.Instantiate to make the game object spawn. I add the Photon View before hand onto the game object. I don't think either of those are the problem because I use photonView.isMine to make a camera follow the person and to give only your person the controls and that works fine. Could the problem be that when I spawn a second person, the !photonView.isMine becomes true so both become green? Would taking out the code with !photonView.isMine fix this? I can't try it right now but does the information I gave you help?
  • I've hit a similar problem with isMine, as used by NetworkRigidbody, in my case a scene object Network.InstanciateSceneObject's the enemy which is fine and works great but when one of the enemy launch a missile ( which the Network.Instantiate or Network.InstanciateSceneObject ) the isMine flag gets set to false which is wrong as there is only one client which created room??!

    The Script that instantiates the new objects is in a sub-object within the hierarchy if this helps.
  • OOPS my bad, apparently when I was launching the missiles I turned off their collision ect, to allow them to clear the launcher and expected a method to be called aptly enough missile.Launch() which would trigger the delayed activation! :oops:
  • :)