So i made a nice weaponwheel script and upgraded my weapon manager to fit it…however every time i call the Debug Weapons function…all the weapons disappear although i call the SetWeapon funtion at the end, which should reenable the weapons…but it doesn’t…the strange thing is that…if i call the SetWeapon function anytime after the DebugWeapons function…the weapons are reenabled…im clueless…here are both of the scripts
[183025-weaponsmanager.txt|183025]
[183026-weaponwheel.txt|183026]
Here is the relevant part of the WeaponsManager script…
public void DebugWeapons()
{
foreach(InventoryWeapon weapon in inventory)
{
if(weapon.colliders == null)
return;
else
{
weapon.colliders.gameObject.SetActive(false);
weapon.weaponcode = Array.FindIndex(inventory, inventory => inventory == weapon);
}
}
weapons[currentweapon].colliders.gameObject.SetActive(true);
SetWeapon(currentweapon);
}
public void SetWeapon(int weaponcode)
{
if(weaponcode < 0)
{
weaponcode = noofweapons - 1;
}
else if(weaponcode > noofweapons - 1)
{
weaponcode = 0;
}
currentweapon = weaponcode;
lastweapon = weaponcode;
InventoryWeapon weapon = weapons[weaponcode];
if(weapon == null)
{
Debug.LogWarning("There's no weapon with the code " + weaponcode);
return;
}
if(!weapon.locked)
{
foreach(InventoryWeapon weaponcheck in weapons)
{
if(weaponcheck.colliders == null)
{
return;
}
else
{
weaponcheck.colliders.maincollider.GetComponent<WeaponCollision>().enemies.Clear();
weaponcheck.colliders.secondarycollider.GetComponent<WeaponCollision>().enemies.Clear();
if(weaponcheck.weaponcode == weaponcode)
{
weaponcheck.colliders.gameObject.SetActive(true);
}
else
{
weaponcheck.colliders.gameObject.SetActive(false);
}
}
}
weapondata = weapon.weapon;
combat.wcolliders = weapon.colliders;
combat.attackrate = weapondata.attackrate;
combat.mindamage = weapondata.mindamage;
combat.maxdamage = weapondata.maxdamage;
combat.currentweapon = weapondata.name;
combat.damagerange = weapondata.damagerange;
}
else
{
if(lastscroll > 0)
{
currentweapon += 1;
}
else if(lastscroll < 0)
{
currentweapon -= 1;
}
}
}
}
Any and all help is appreciated…Thanks in advance!