Hi, can anyone help me. I am tempting to use multiple transforms to instantiate multiple bullets at the same time, but i can’t make the script spawn bullets from the array of transforms.
Thanks for helping. This is my code:
public Transform [] gunTip;
public Rigidbody bullet;
public float fireRate;
public int Ammo;
public int curAmmo;
public int ammoConsumed;
private float nextFire;
void Start(){
curAmmo = Ammo;
}
void Update () {
for (int i = 0; i < gunTip.Length; i++) {
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
if (curAmmo > 0) {
Rigidbody bulletInstance;
bulletInstance = Instantiate (bullet, gunTip_.position, gunTip*.rotation) as Rigidbody;*_
bulletInstance.AddForce (gunTip_.forward * 500);_
* curAmmo -= ammoConsumed;*
* }*
* }*
* }*
* }*
}