Graphics Reference
In-Depth Information
Enabling the currently selected weapon is done by the EnableCurrentWeapon() func-
tion, which works almost exactly the same as DisableCurrentWeapon() except that it calls
the Enable() function of the BaseWeaponScript instead of Disable():
public virtual void EnableCurrentWeapon ()
{
if( weaponScripts.Count==0 )
return;
// grab reference to currently selected weapon
TEMPWeapon= ( BaseWeaponScript )weaponScripts[selectedWeapon
Slot];
// now tell the script to enable itself
TEMPWeapon.Enable();
TEMPgameObject= ( GameObject )weaponSlots[selectedWeapon
Slot];
TEMPgameObject.SetActive( true );
}
By default, the Fire() function will launch projectiles along the transform's forward
axis, but there is support for firing along a fixed vector by setting the useForceVectorDi-
rection to true.
The function takes no parameters, making it easy to call from any other script:
public virtual void Fire ()
{
The weaponScripts ArrayList is checked to make sure that it has been properly initial-
ized and that it contains entries (a quick count check):
if(weaponScripts==null)
return;
if(weaponScripts.Count==0)
return;
TEMPWeapon gets a reference to the currently selected weapon's script from the
weaponScripts array:
// find the weapon in the currently selected slot
TEMPWeapon= ( BaseWeaponScript )weaponScripts[selectedWeapon
Slot];
By default, the firing direction is along the transform's forward vector:
theDir = myTransform.forward;
Search WWH ::




Custom Search