Graphics Reference
In-Depth Information
A function is provided to return the value of vert, the vertical axis provided by the
virtual axis named Vertical:
public virtual float GetVertical()
{
// returns our cached vertical input axis value
return vert;
}
GetFire() returns the value of the Boolean variable Fire1. GetRespawn() returns the
value of the Boolean variable shouldRespawn. At this stage, you may notice that there is
no actual code to set either Fire1 or shouldRespawn in this default input script. They are
both provided as a guide and with the intention of being built upon on a case-by-case basis
depending on what the game requires:
public virtual bool GetFire()
{
return Fire1;
}
public bool GetRespawn()
{
return shouldRespawn;
}
It may be useful in some circumstances to have a movement vector rather than hav-
ing to process the numbers from horz and vert. GetMovementDirectionVector() will
return a Vector3 type vector based on the current state of input. Here, TEMPVec3 receives
input values and gets returned by the function
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;
The vector starts out at 0,0,0, but its x and y values will be set to the values of horz
and vert, respectively. Finally, the vector in TEMPVec3 is returned:
TEMPVec3.x=horz;
TEMPVec3.y=vert;
// return the movement vector
return TEMPVec3;
}
}
Search WWH ::




Custom Search