Yes, you can use the OnDeath event to get the name. This thread is from a bug report that has been fixed but it gives an example.
Reference - PunHealthMonitor.cs This Script is attached to the Character. When Character is Dying OnDie Function is Called But Attacker is null so that else Condition executed . As you can see in the Pic var attacker = damageData.DamageSource?.SourceOwner; in this attacker is null when...
www.opsive.com
Hello Justin,
public void Awake()
{
Debug.Log("Here we are");
EventHandler.RegisterEvent<Vector3, Vector3, GameObject>(gameObject, "OnDeath", OnDeath);
}
/// <summary>
/// The object has died.
/// </summary>
/// <param name="position">The position of the force.</param>
/// <param name="force">The amount of force which killed the object</param>
/// <param name="attacker">The GameObject that killed the object</param>
public void OnDeath(Vector3 position, Vector3 force, GameObject attacker)
{
Debug.Log("The object " + gameObject.name + " died.");
if (attacker != null)
{
Instantiate(killMessageUI);
Debug.Log(gameObject.name + "Is Dead");
playerUI.KilledNickName.text = this.gameObject.GetComponent<PhotonView>().Owner.NickName;
playerUI.KillerNickName.text = attacker.GetComponent<PhotonView>().Owner.NickName;
Destroy(killMessageUI, 3f);
}
when there's no condition (means i don't put th if statment if(attacker != null) it gives back the name of the dead player, but the attacker name is alwys null (empty), can you please help me find the problem ?
thanks in advance;