Graphics Reference
In-Depth Information
Although the script includes a function called GetFire(), returning the value of the
Boolean variable Fire1, the script does not include any code to set it. It's just there for
consistency.
public virtual bool GetFire()
{
return Fire1;
}
Again, the script contains GetRespawn() purely for protocol, with no actual functionality.
public bool GetRespawn()
{
return shouldRespawn;
}
For convenience, BaseInputController.cs includes a simple system for returning a
direction vector. The function will return a Vector3 with its x and y axes representing the
levels of input:
public virtual Vector3 GetMovementDirectionVector()
{
// temp vector for movement dir gets set to the value of an
// otherwise unused vector that always has the value of 0,0,0
TEMPVec3=zeroVector;
// if we're going left or right, set the velocity vector's X
// to our horizontal input value
if(Left || Right)
{
TEMPVec3.x=horz;
}
// if we're going up or down, set the velocity vector's X to
// our vertical input value
if(Up || Down)
{
TEMPVec3.y=vert;
}
// return the movement vector
return TEMPVec3;
}
}
The default script for input is a basic keyboard setup script named Keyboard_Input.cs.
It derives from BaseInputController.cs and overrides the CheckInput() and LateUpdate()
functions to add a vertical axis, checking for the fire button and a respawn button set up
as Fire3 in Unity's Input Manager:
public class Keyboard_Input : BaseInputController
{
public override void CheckInput ()
{
// get input data from vertical and horizontal axis and
Search WWH ::




Custom Search