Graphics Reference
In-Depth Information
When the Boolean variable isRaceRunning is false, the race is over for this player,
and the LateUpdate() function needs to ignore input. Instead of getting the inputs for the
vehicle, this code just disables the gun control script (gunControl) so that nobody can fire
ater the game ends:
if(isAIControlled)
{
// since the race is not running, we'll tell
// the AI gunControl not to fire yet
gunControl.canControl=false;
}
}
The race controller always needs to track waypoints for position tracking and lap
counting, regardless of whether or not the race is still running. raceControl does not call
its own update function so the next part of LateUpdate() calls UpdateWaypoints() to keep
it updating:
// tell the race controller to update
raceControl.UpdateWaypoints();
The code continues by calling CheckLock() to see whether or not the vehicle should
be held in place, and then there is a call out to raceControl to CheckWrongWay():
// see if our car is supposed to be held in place
CheckLock();
// tell race control to see if we're going the wrong way
raceControl.CheckWrongWay();
When raceControl detects that the vehicle is traveling around the track the wrong way,
the assumption is made that a non-AI-controlled player will be the user. The code below
tells the game controller to update its wrong-way status, with a call to GameController_
MVD.Instance.UpdateWrongWay():
// check to see if we're going the wrong way and act on it
if(raceControl.goingWrongWay)
{
if (!isAIControlled)
GameController_MVD.Instance.UpdateWrongWay(true);
When raceControl first detects that the vehicle is heading in the wrong direction, its
timeWrongWayStarted variable acts like a timestamp as it is set to the value of the system
property Time.time. This code checks against raceControl.timeWrongWayStarted and
Time.time to see whether the vehicle has been going in the wrong way for longer than the
time set by the variable resetTime:
// if going the wrong way, compare time since wrong
// way started to see if we need to respawn
if(raceControl.timeWrongWayStarted!=-1)
timedif= Time.time -
raceControl.timeWrongWayStarted;
if(timedif>resetTime)
Search WWH ::




Custom Search