I use the GetDamage
method in my PlayerManager
script on enemy objects.
I want to use the AmIDead
method and my amIDead
variable in the PlayerMovement
script to activate the Restart Menu
canvas when my character dies, but I cannot change it.
What should I not do?
PlayerMovement
if (deadCheck.amIDead == true)
{
restartMenu.SetActive(true);
}
PlayerManager
public float health;
public bool amIDead = false;
public void GetDamage(float damage)
{
if ((health - damage) > 0)
{
health -= damage;
}
else
{
health = 0;
Destroy(GameObject.FindWithTag("Player"));
}
AmIDead();
}
void AmIDead()
{
if (health <= 0)
{
amIDead = true;
}
}