Created
December 23, 2019 09:14
-
-
Save IshidaGames/b9c6312a9d4cefc15a4140c3710f450c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class PresentBomb : MonoBehaviour | |
{ | |
private GameObject present; | |
private GameObject explosion; | |
private bool bomb = true; | |
AudioSource audioSource; | |
void Start() | |
{ | |
present = transform.Find("Present").gameObject; | |
explosion = transform.Find("Detonator-Spray").gameObject; | |
present.SetActive(true); | |
explosion.SetActive(false); | |
audioSource = GetComponent<AudioSource>(); | |
} | |
private void OnCollisionEnter(UnityEngine.Collision collision) | |
{ | |
if (bomb) | |
{ | |
present.SetActive(false); | |
explosion.SetActive(true); | |
bomb = false; | |
audioSource.Play(); | |
Invoke("BombDestroy", 1f); | |
} | |
} | |
private void BombDestroy() | |
{ | |
explosion.SetActive(false); | |
//Destroy(this.gameObject); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment