- Home /
Gun Manager only working once
Hello, everyone. I am working on a gun manager script (similar to the one in the bootcamp demo, but not exactly the same), but it only checks if I press the key once, so I can only change guns once.
My code looks like this :
var guns : GameObject[]; var startGun : int;
private var gunInt : int;
function Awake() { for(var i = 0; i < guns.length; i++) { guns[i].active = false; } gunInt = 0; guns[startGun].active = true; } function FixedUpdate () { for(var i = 0; i < guns.length; i++) { if(Input.GetKey(guns[i].GetComponent(Gun).keyToActivate)) { ChangeToGun(i); } } } function ChangeToGun(newGun : int) { for(var i = 0; i < guns.length; i++) { guns[i].active = false; } guns[newGun].active = true; gunInt = newGun; }
What key? The script implies that you should be using several keys, and that mashing on the same one will not produce multiple results.
Your answer
Follow this Question
Related Questions
Camera Recoil,Please help me. 2 Answers
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
C# How to have weapon pickup 1 Answer
FPS Scripting Problems 2 Answers
gun bob and jerk animation 2 Answers