Hi, I am trying to make two guns shoot, (at the same time) by pressing and or holding down the left an right mouse buttons, but so far I can only shoot them individually. I’m new to programing and have likely placed my script in the wrong place or something. here is what I have:
public GameObject PriShot;
public Transform Gun1;
public Transform Gun2;
public float fireRate1;
public float fireRate2;
private float nextFire;
void Start ()
{
anim = GetComponent<Animator>();
}
void Update()
{
if (Input.GetButton ("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate1;
Instantiate(PriShot, Gun1.position, Gun1.rotation);
}
{
if (Input.GetButton ("Fire2") && Time.time > nextFire)
{
nextFire = Time.time + fireRate2;
Instantiate (PriShot, Gun2.position, Gun2.rotation);
}
}
}
void FixedUpdate()
If anyone has a recommendation, I would love to hear your thoughts 
and Thanks!
A better approach would be to create a single FireBullet script that instantiates and fires a bullet from the position of the object that the script it attached to, and then attach that script to each gun individually.
To create the bullets like that, you’ll need:
Instantiate(PriShot, gameObject.transform.position, gameObject.transform.rotation);
Ah, thank you so much for the advice! I assigned two different controllers to my guns and they work fabulously now! For anyone with the same problem, here is my new code;
{
public Rigidbody2D PriShot;
public float speed = 20f;
public Transform Gun1;
public float fireRate1;
private float nextFire;
private PlayerScript playerScr; // Reference to the PlayerControl script.
private Animator anim; // Reference to the Animator component.
void Awake()
{
// Setting up the references.
anim = transform.root.gameObject.GetComponent<Animator>();
playerScr = transform.root.GetComponent<PlayerScript>();
}
void Update ()
{
if (Input.GetButton ("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate1;
Instantiate(PriShot, Gun1.position, Gun1.rotation);
}
I then duplicated this script and assigned it to another game object called Gun2, and adjusted the parameters in the script to match. Now my 2 guns fire independently, and can be shot at the same time! Thank you KevLoughrey, cheers!