using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Gun : MonoBehaviour
{
public GameObject bulletprefab;
public Transform firePoint;
public float fireForce = 10f;
///
/// this is to creat and calculate the direction and speed of the bullet
///
public void Fire()
{
// creating the bullet
GameObject bullet = Instantiate(bulletprefab, firePoint.position, firePoint.rotation);
// setting the speed of the bullet
bullet.GetComponent().AddForce(firePoint.up * fireForce, ForceMode2D.Impulse);
}
}