using UnityEngine;

public class GunProjectile : MonoBehaviour {
    public float velocity = 10;
    public float explodeDelay = 4;
    public GameObject explosionPrefab;

    private void Start() {
        Invoke("Explode", explodeDelay);
    }

    void FixedUpdate () {
		transform.position += transform.forward * velocity;
	}

    public void Explode() { 
        Instantiate(explosionPrefab, transform.position, Quaternion.Euler(-90, 0, 0));
        Destroy(gameObject);
    }

    void OnTriggerEnter(Collider other){
        if(other.tag == "Tiger" || other.tag == "Deer" || other.tag == "Ground")
            Explode();
    }
}
