Graphics Reference
In-Depth Information
Transform tempT= (Transform)playerTransforms[i];
CarController_TB tempController= tempT.
GetComponent<CarController_TB>();
playerList.Add(tempController);
BaseAIController tempAI=tempController.GetComponent
<BaseAIController>();
tempController.Init ();
if( i>0 )
{
// grab a ref to the player's gameobject for
// later use
playerGO1 = SpawnController.Instance.GetPlayerGO( 0 );
// tell AI to get the player!
tempAI.SetChaseTarget( playerGO1.transform );
// set AI mode to chase
tempAI.SetAIState( AIStates.AIState.steer_to_
target );
}
}
// 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 );
Search WWH ::




Custom Search