Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void OnTriggerEnter(Collider col)
- {
- if (!collided)
- {
- collided = true;
- Explode();
- }
- }
- void Explode()
- {
- Debug.Log("Collision Detected");
- Debug.Log("PlayingSound");
- gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;
- explosion.Play();
- StartCoroutine(waitForExplosion());
- }
- IEnumerator waitForExplosion()
- {
- Debug.Log("Waiting for sound to play");
- yield return new WaitWhile(()=> explosion.isPlaying);
- GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy");
- foreach (GameObject Enemy in enemies)
- {
- if (damageRadius >= Vector3.Distance(transform.position, Enemy.transform.position))
- {
- //Enemy.getComponent(HealthScript).takeDamage(100);
- Debug.Log("Max Damage!");
- }
- }
- Debug.Log("Destroying");
- Destroy(gameObject);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement