I’m trying to understand the code for the logic I’m trying to implement, but it’s not cooperating like I expect. Essentially, a player collides with a box, and when that triggers, it calls the function GetHeal();
Currently what happens is the player is healed, the gameObject is set to inactive, but never gets set back to active after the WaitForSeconds. I’m sure there’s a better way to do this, but I figured this was the easiest. Any help is appreciated.
float healAmount = 20f;
public int GetHeal()
{
StartCoroutine(RespawnPowerUp());
return healAmount;
}
public IEnumerator RespawnPowerUp()
{
gameObject.SetActive(false);
yield return new WaitForSeconds(1);
gameObject.SetActive(true);
}