using UnityEngine;
public class Gun : MonoBehaviour
{
public Transform spawnPoint;
public float force = 10;
public GameObject bullet;
Interactable interactable;
void Start()
{
interactable = GetComponent<Interactable>();
}
// Update is called once per frame
void Update()
{
if (interactable.isGrabbable && Input.GetMouseButtonDown(0))
{
GameObject newBullet = Instantiate(bullet, spawnPoint.position, Quaternion.identity);
newBullet.GetComponent<Rigidbody>().AddForce(spawnPoint.forward * force, ForceMode.Impulse);
}
}
}