I am trying to find a way so that when my player comes in contact through a trigger on the enemy it will make the play invincible and not lose any health, can you give me hints on how to do that.
This is what i use in my game.
public void DestroyShip()
{
if (!invincible)
{
animator.SetBool("Explode", true);
destroyOverLifetime.shouldWait = false;
FindObjectOfType<PlayerMovement>().CantMove();
invincible = true;
if (PlayerDataManager.instance.lives > 0 ) {
PlayerDataManager.instance.RemoveExtraLife();
}
else
{
SceneManager.LoadScene("GameOver");
}
}
}
if the ship is hit. the DestroyShip funtion is called.
Then if the bool invincible is true. nothing happens.
p.s. the naming of my method is not the way to go… Renaming it right now