Getting the player who killed

I have a trigger for when a player is struck that will take damage. in the take damage method if the player dies I want to be able to find the correct player that struck the player and add a kill score to the player that struck.

if(myTrigger.gameObject.tag == "Strike" && photonView.isMine //Striking the player and taking health
{
strikeObject = myTrigger.gameObject;
playerHealth.TakeDamage(70, strikeObject);
}

public void TakeDamage ( int amount, GameObject damager) {

currentHealth -= amount;

if(currentHealth <= 0 && !isDead)
{
PlayerScore playerScore = damager.GetComponent<PlayerScore>(); //Thought I was getting the player that killed here
playerScore.UpdateKills();
Death();
}

}

public void UpdateKills()
{
totalKills = (int)PhotonNetwork.player.customProperties["Kills"];
totalKills++;
ExitGames.Client.Photon.Hashtable setPlayerKills = new ExitGames.Client.Photon.Hashtable();
setPlayerKills.Add ("Kills", totalKills);
PhotonNetwork.player.SetCustomProperties(setPlayerKills);
}


What is happening here is the player who dies is the player that gets kills updated on the screen. The player who killed is not getting updated.


Comments