Hello I am creating a special health zone that gives the player health and my current scripts health is going up super fast and I want it to go up by 2 hp per second. How would I do this?
Here is the health zone script.
{ public PlayerHealth playerHealth; public float healthGain = 2f; void OnTriggerStay2D(Collider2D other) { if (playerHealth.currentHealth < playerHealth.maxHealth) { playerHealth.currentHealth += (int)healthGain; playerHealth.healthBar.SetHealth(playerHealth.currentHealth); } if (playerHealth.currentHealth >= playerHealth.maxHealth) { playerHealth.currentHealth = playerHealth.maxHealth; playerHealth.healthBar.SetHealth(playerHealth.currentHealth); } } }