Skip to content
Snippets Groups Projects
Commit e2df2c43 authored by N2970's avatar N2970
Browse files

more tweeks to bomb explosion animation

parent fd175c24
No related branches found
No related tags found
No related merge requests found
......@@ -8,29 +8,32 @@ public class BombCollectible : MonoBehaviour
{
public bool isExploded = false;
Animator animator;
PlayerController controller;
PlayerController controller;
private void OnTriggerEnter2D(Collider2D other)
void Start()
{
animator = GetComponent<Animator>();
}
private void OnTriggerEnter2D(Collider2D other)
{
controller = other.GetComponent<PlayerController>();
if (controller != null && isExploded == false)
{
isExploded = true;
animator.SetBool("isExploded", true);
StartCoroutine(waiter());
Invoke("Explode", 1f);
}
}
IEnumerator waiter()
void Explode()
{
yield return new WaitForSeconds(1);
controller.ChangeHealth(-1);
Destroy(gameObject);
gameObject.SetActive(false);
}
}
// https://stackoverflow.com/questions/30056471/how-to-make-the-script-wait-sleep-in-a-simple-way-in-unity
......
......@@ -44,7 +44,8 @@ public class PlayerController : MonoBehaviour
void Start()
{
controller = gameObject.GetComponent<PlayerController>();
currentHealth = 3;
animator = GetComponent<Animator>();
currentHealth = maxHealth;
}
private void Awake()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment