i have a code for health and in the code i have a code so i would die on collision with the enemy, the enemy has a riged body and my charector does too and we both have a charector.collider() or whatever it is but the code is not working please help!
the code is:
var PlayerHealth: float = 10.0;
var EnemyDamage: float = 10.0;//(damage per sec)You may change it to kill player quickly
function OnTriggerStay(enemy: Collider){
if(enemy.CompareTag("Enemy"))
{
PlayerHealth-=EnemyDamage*Time.deltaTime;
}
if(PlayerHealth<0)
{
Debug.Log("Player died.You lost!");
Destroy(gameObject);
}
}