Graphics Reference
In-Depth Information
In Metal Vehicle Doom , the default state for the AI was for it to follow waypoints in
AIState.steer_to_waypoint. In this game, rather than path following, the enemy players
need to go on the attack, and their first state is AIState.steer_to_target, which means that
the AI provides steering inputs that should point its vehicle at its chase target:
// set AI mode to chase
tempAI.SetAIState( AIStates.AIState.steer_to_target );
}
}
The AudioListener component is removed from the camera and added to the user's
tank, instead:
// add an audio listener to the first car so that the audio
// is based from the car rather than from the main camera
playerGO1.AddComponent<AudioListener>();
// look at the main camera and see if it has an audio
// listener attached
AudioListener tempListener=
Camera.main.GetComponent<AudioListener>();
// if we found a listener, let's destroy it
if( tempListener!=null )
Destroy(tempListener);
// grab a reference to the focussed player's car controller script,
// so that we can do things like access its speed variable
thePlayerScript = ( CarController_TB )
playerGO1.GetComponent<CarController_TB>();
// assign this player the id of 0 - this is important. The id
// system is how we will know who is firing bullets!
thePlayerScript.SetID( 0 );
// set player control
thePlayerScript.SetUserInput( true );
// as this is the user, we want to focus on this for UI etc.
focusPlayerScript = thePlayerScript;
// tell the camera script to target this new player
cameraScript.SetTarget( playerGO1.transform );
// lock all the players on the spot until we're ready to go
SetPlayerLocks( true );
// start the game in 3 seconds from now
Invoke( "StartGame", 4 );
The game is timed. The winner is the player who has the highest frag count when
the timer finishes. A simple TimerClass script is used to manage the timing, which gets
instanced here and a reference held by the variable theTimer:
// initialize a timer, but we won't start it right away. It
// gets started in the FinishedCount() function after the
// count-in
theTimer = ScriptableObject.CreateInstance<TimerClass>();
Search WWH ::




Custom Search