Graphics Reference
In-Depth Information
public bool Left;
public bool Right;
// fire/action buttons
public bool Fire1;
The slot-based weapon system uses the keyboard buttons from 1 to 9 to directly select
which weapon slot to use. For that reason, the input system has nine Boolean variables to
take input from the number keys:
// weapon slots
public bool Slot1;
public bool Slot2;
public bool Slot3;
public bool Slot4;
public bool Slot5;
public bool Slot6;
public bool Slot7;
public bool Slot8;
public bool Slot9;
public float vert;
public float horz;
public bool shouldRespawn;
public Vector3 TEMPVec3;
private Vector3 zeroVector = new Vector3(0,0,0);
Input provides an interface to Unity's input systems. It is used for everything from
gyrometer input on mobile devices to keyboard presses. According to the Unity docu-
mentation, Input.GetAxis returns the value of the virtual axis identified by axisName.
The axis names are set in Unity's Input Manager (Edit → Project Settings → Input), although
Horizontal and Vertical should already be set up by default:
public virtual void CheckInput ()
{
// override with your own code to deal with input
horz=Input.GetAxis ("Horizontal");
vert=Input.GetAxis ("Vertical");
}
public virtual float GetHorizontal()
{
// returns our cached horizontal input axis value
return horz;
}
public virtual float GetVertical()
{
// returns our cached vertical input axis value
return vert;
}
Search WWH ::




Custom Search