Skip to content

Instantly share code, notes, and snippets.

@IshidaGames
Created December 23, 2019 09:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IshidaGames/b9c6312a9d4cefc15a4140c3710f450c to your computer and use it in GitHub Desktop.
Save IshidaGames/b9c6312a9d4cefc15a4140c3710f450c to your computer and use it in GitHub Desktop.
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