Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public IEnumerator TakeWorldDamage(float damagePerSecond)
- {
- while (canTakeDamage)
- {
- health -= damagePerSecond;
- health = Mathf.Clamp(health, 0.0f, maxHealth);
- Debug.Log("You took " + damagePerSecond + " damage from the world.");
- yield return new WaitForSeconds(1.0f);
- }
- }
- public void OnTriggerEnter(Collider other)
- {
- if (other.tag == "Lava")
- {
- canTakeDamage = true;
- StartCoroutine(TakeWorldDamage(10.0f));
- }
- }
- public void OnTriggerExit(Collider other)
- {
- if (other.tag == "Lava")
- {
- canTakeDamage = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement