Graphics Reference
In-Depth Information
if(!didInit)
return;
// check to see if we're supposed to be controlling the
// player before checking for firing
if(!canControl)
return;
}
public override void GetInput ()
{
// we're overriding the default input function to add in the
// ability to fire
horizontal_input= default_input.GetHorizontal();
vertical_input= default_input.GetVertical();
}
void OnCollisionEnter(Collision collider)
{
// React to collisions here
}
void OnTriggerEnter(Collider other)
{
// React to triggers here
}
public void PlayerFinished()
{
// Deal with the end of the game for this player
}
public void ScoredPoints(int howMany)
{
myDataManager.AddScore( howMany );
}
}
3.2 Dealing with Input
Separate scripts provide input for the movement controllers to react to. This is so they may
be switched out for whatever input is required, without having to change anything within
the movement control script. The movement controller remains intact, regardless of what
you “feed” into it, which means you could use the exact same movement control script
for the main player, for AI players, and perhaps even for remote players connected over a
network—just using different inputs.
BaseInputController.cs provides a collection of common variables and functions.
Other input scripts will derive from it:
public class BaseInputController : MonoBehavior
{
// directional buttons
public bool Up;
public bool Down;
Search WWH ::




Custom Search