Hi.
I have a script called scr_WeaponController which stores all player’s weapons in an array. I use the following script to switch between the weapons:
void SwitchWeapon(int index)
{
for (int i = 0; i < weaponCount; i++)
{
if (i == index)
{
weapons*.gameObject.SetActive(true);*
}
else {
weapons*.gameObject.SetActive(false);*
}
}
}
Now each weapon object contains a script: “scr_weapon” with a function: “GetWeapon()” which sends all the information about said weapon (damage per shot, time between bullets, bullet spread etc.) forward to another script which does the shooting.
I’m trying to access the scr_Weapon script from the scr_WeaponController script like so:
void SwitchWeapon(int index)
{
for (int i = 0; i < weaponCount; i++)
{
if (i == index)
{
weapons*.gameObject.SetActive(true);*
weapons*.GetComponent<scr_weapon>.GetWeapon();
_}
else {_
_weapons.gameObject.SetActive(false);
}
}
}*
Now it seems like I can’t do it that way but I’m having a severe brain fart and can’t figure out why. All help is greatly appreciated.
Thanks!_