﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MissileExplode : MonoBehaviour {

	public AudioClip sound;
	public float lifetime;
	public float minSoundRange;
	public float maxSoundRange;

	void Start () {
	}
	
	void Update () {
	}

	void Destroy (){

		gameObject.SetActive(false);
	}


	void OnEnable () {

		GetComponent<AudioSource>().pitch = Random.Range(minSoundRange, maxSoundRange);
		GetComponent<AudioSource>().PlayOneShot(sound);
		Invoke ("Destroy", lifetime);
	}
	
	void OnDisable (){

		CancelInvoke();
	}
}
