I have a fighter jet which has 6 guns in it. I want to fire bullets with all six guns at the same time when i hit fire. The script used to fire bullet with 1 gun is attached below:
public class bullet_fire : MonoBehaviour {
public GameObject Bullet_Emitter;
public GameObject Bullet;
public float Bullet_Forward_Force;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
if(Input.GetButtonDown("Fire1"))
{
GameObject temp_bullet_hsndler;
temp_bullet_hsndler = Instantiate(Bullet, Bullet_Emitter.transform.position, Bullet_Emitter.transform.rotation) as GameObject;
temp_bullet_hsndler.transform.Rotate(Vector3.left * 90);
Rigidbody temp_rigidbody;
temp_rigidbody = temp_bullet_hsndler.GetComponent<Rigidbody>();
temp_rigidbody.AddForce(transform.forward * Bullet_Forward_Force);
Destroy(temp_bullet_hsndler, 3.0f);
}
}
}