So, i made this code to switch weapons, and all i'm trying to do is get how much weapons the player has, so i know how to set the array, and then, put all weapons into the array, however, how do i get the objects with the "WeaponFire" component?
BTW, this is not an FPS, nor a TPS, it is a car combat game.
Code:
#pragma strict
var currentWeapon = 0;
var Weapons : WeaponFire[];
function getSelectedWeapon() : WeaponFire
{
return Weapons[currentWeapon];
}
function Start()
{
if (currentWeapon >= Weapons.length) currentWeapon = Weapons.length-1;
for (var i=0; i= Weapons.length) currentWeapon = 0;
SelectWeapon(Weapons[currentWeapon]);
}
function DisableWeapon(Weapon : WeaponFire)
{
Weapon.weaponSelected = false;
}
function SelectWeapon(Weapon : WeaponFire)
{
Weapon.weaponSelected = true;
}
↧