using UnityEngine;
using System.Collections;

public class Shoot : MonoBehaviour {

	public AudioClip deathSound;
	public AudioSource audio;
	public GameObject explosion;
	private GameObject gameobject;
	
	void Awake(){
		audio = GetComponent<AudioSource>();
	}
	void Start(){
		gameobject =GetComponent<GameObject>();
	}
	void Update(){
		Destroy(gameobject,3f);
	}
	
	//handle the collision with player
	void OntriggerEnter(Collider other){
		if(other.tag =="player"){
			Debug.Log("Player Dead");
			Destroy(other);
			audio.PlayOneShot(deathSound,1f);
			Destroy(gameObject);
			Instantiate(explosion,transform.position,transform.rotation);
		}
	}
}