I’m creating a fps game and i have a list of weapons that the player can switch between but for some reason gun number 1 does not work. gun 0 works as well as gun 2 and up it’s really bugging me here is a copy of the code.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Gun_Switch : MonoBehaviour {
public PerformAllAttacks script;
public Gun_List script2;
// Update is called once per frame
void Update () {
if( Input.GetButtonDown("Switch Weapons") && script.currentGun < script2.currentCount ) {
Weapon_Change();
}
else if( Input.GetButtonDown("Switch Weapons") && script.currentGun >= script2.currentCount ) {
First_Weapon();
}
}
void Weapon_Change() {
Guns Result = script2.CurrentGuns.Find(
delegate(Guns Gn)
{
return Gn.gunCount == script.currentGun;
}
);
if (Result != null)
{
script.gunType = Result.gunType;
script.Range = Result.Range;
script.Damage = Result.Damage;
script.Accuracy = Result.Accuracy;
script.shotsFired = Result.shotsFired;
script.vertRecoil = Result.vertRecoil;
script.sideRecoil = Result.sideRecoil;
script.maxClip = Result.maxClip;
script.maxAmmo = Result.maxAmmo;
script.coolDown = Result.coolDown;
}
script.currentGun += 1;
script.lastGun = script2.currentCount;
}
void First_Weapon() {
Guns Result = script2.CurrentGuns.Find(
delegate(Guns Gn)
{
return Gn.gunCount == 0;
}
);
if (Result != null)
{
script.gunType = Result.gunType;
script.Range = Result.Range;
script.Damage = Result.Damage;
script.Accuracy = Result.Accuracy;
script.shotsFired = Result.shotsFired;
script.vertRecoil = Result.vertRecoil;
script.sideRecoil = Result.sideRecoil;
script.maxClip = Result.maxClip;
script.maxAmmo = Result.maxAmmo;
script.coolDown = Result.coolDown;
}
script.currentGun = 0;
script.lastGun = script2.currentCount;
}
}