using UnityEngine;

public class Shooting : MonoBehaviour
{
    public Transform firePoint;
    public GameObject firePointPrefab;
    public KeyCode fire = KeyCode.G;

    public float bulletForce = 20f;

    void Update()
    {
        if (Input.GetKeyDown(fire))
        {
            shoot();
        }
    }

    void shoot()
    {
        GameObject bullet = Instantiate(firePointPrefab, firePoint.position, firePoint.rotation);
        Rigidbody2D rb = bullet.GetComponent<Rigidbody2D>();
        rb.AddForce(firePoint.up * bulletForce, ForceMode2D.Impulse);
    }
}
