The code I’m about to show worked correctly up until I made a few changes in the editor and now it no longer works. All I did was add GUI windows so I’m not sure how this happened.
[RPC]
public void GetShot(float damage, PhotonPlayer enemy){
//Take Damage and check for death
health -= damage;
if(health <=0 && alive){
alive = false;
Debug.Log ("<color=blue>Checking Health</color>" + health + " Alive: " + alive);
if (photonView.isMine) {
Debug.Log ("Death");
if(SendNetworkMessage != null){
SendNetworkMessage(PhotonNetwork.player.name + " got owned by " + enemy.name);
}
//Subscribe to the event so that when a player dies 3 sec later respawn
if(RespawnMe != null)
RespawnMe(3f);
//Only owner can remove themselves
//Create deaths equal to stored hashtable deaths, increment, Set
int totalDeaths = (int)PhotonNetwork.player.customProperties["D"];
totalDeaths ++;
ExitGames.Client.Photon.Hashtable setPlayerDeaths = new ExitGames.Client.Photon.Hashtable() {{"D", totalDeaths}};
PhotonNetwork.player.SetCustomProperties(setPlayerDeaths);
//Destroy Object on network
Debug.Log ("<color=green> Collider State After</color>"+transform.GetComponent<Collider>().enabled.ToString());
PhotonNetwork.Destroy(gameObject);
foreach(PhotonPlayer p in PhotonNetwork.playerList)
Debug.Log ("<color=red>PlayerLIst</color>" + p.name);
}
else{
if(PhotonNetwork.player == enemy){
int totalKIlls = (int)PhotonNetwork.player.customProperties["K"];
totalKIlls ++;
ExitGames.Client.Photon.Hashtable setPlayerKills = new ExitGames.Client.Photon.Hashtable() {{"K", totalKIlls}};
Debug.Log ("<color=red>KillCounter Called at </color>" + totalKIlls);
PhotonNetwork.player.SetCustomProperties(setPlayerKills);
}
}
}
}
It will execute everything that isn’t int he PhotonView.isMine. If I take it out it still wont’ execute what is in the myphoton view. I just don’t get it. No errors either.