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*.active = false;*
*}*
*gunInt = 0;*
*guns[startGun].active = true;*
*}*
*function FixedUpdate ()*
*{*
*for(var i = 0; i < guns.length; i++)*
*{*
_if(Input.GetKey(guns*.GetComponent(Gun).keyToActivate))*_
_*{*_
_*ChangeToGun(i);*_
_*}*_
_*}*_
_*}*_
_*function ChangeToGun(newGun : int)*_
_*{*_
_*for(var i = 0; i < guns.length; i++)*_
_*{*_
<em>_guns*.active = false;*_</em>
<em>_*}*_</em>
<em>_*guns[newGun].active = true;*_</em>
<em>_*gunInt = newGun;*_</em>
<em>_*}*_</em>
<em>_*```*_</em>