using System.Collections;
using System.Collections.Generic;
using Unity.Mathematics;
using Unity.VisualScripting;
using UnityEngine;

public class Projectile : MonoBehaviour
{
    public GameObject impact;
    public float force = 0;
    public int damage = 1;
    public AudioClip blop;
    void Start()
    {
        GetComponent<Rigidbody>().AddForce(transform.forward*force, ForceMode.Impulse);
        Destroy(gameObject, 3);
    }

    void OnCollisionEnter(Collision collision){
        if(collision.transform.CompareTag("Player")){
            collision.transform.GetComponent<Health>().Damage(damage);
        }
        Instantiate(impact, transform.position, Quaternion.Inverse(transform.rotation));
        AudioSource.PlayClipAtPoint(blop, transform.position);
        Destroy(gameObject);
    }
}
