using UnityEngine;

public class Hitdec : MonoBehaviour
{
    public GameObject projectilePrefab;
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {

    }

    // Update is called once per frame
    private void OnCollisionEnter(Collision collision)
    {
        var v = Instantiate(projectilePrefab);
        v.transform.position = collision.transform.position;

        Vector3 norm = collision.GetContact(0).normal;
        float angle = Vector3.SignedAngle(-transform.forward, norm, Vector3.up);
        v.transform.eulerAngles = new Vector3(0, angle, 0);
    }
}
