Hello! What event do I need to trigger to kill the player?
For example: I have a mine. When the mine is touched, an explosion occurs and the player must die. How can I make the player die?
Player death event
- Lovatto
- Admin
- Posts: 1834
- Joined: Sun Dec 07, 2014 3:18 pm
- Contact:
Hi,
If you want to deal damage to the local player you can call the function DoDamage(...) of bl_PlayerHealthManager.cs which expects a DamageData with the information about the damage, e.g:
I hope this helps,
Regards.
If you want to deal damage to the local player you can call the function DoDamage(...) of bl_PlayerHealthManager.cs which expects a DamageData with the information about the damage, e.g:
Code: Select all
void DealDamageFunction()
{
if(Physics.Raycast(transform.position, transform.forward, out RaycastHit raycast, 10))
{
if (raycast.collider.isLocalPlayerCollider())
{
var playerReferences = raycast.transform.GetComponent<bl_PlayerReferences>();
DamageData damageData = new DamageData()
{
Damage = 20, // base damage to apply
Direction = transform.position,
Cause = DamageCause.Player,
MFPSActor = bl_MFPS.LocalPlayer.MFPSActor, // MFPS actor that cause this damage
// Check the other DamageData properties
};
playerReferences.playerHealthManager.DoDamage(damageData);
}
}
}
Regards.