Graphics Reference
In-Depth Information
private int myRacePosition;
private bool isRaceRunning;
private float resetTimer;
private bool canRespawn;
private bool canPlayFireSound;
public float timeBetweenFireSounds= 0.25f;
public override void Start ()
{
// we are overriding the Start function of BaseVehicle
// because we do not want to initialize from here! Game
// controller will call Init when it is ready
myBody= rigidbody;
myGO= gameObject;
myTransform= transform;
}
public override void Init ()
{
Debug.Log ("CarController_MVD Init called.");
// cache the usual suspects
myBody= rigidbody;
myGO= gameObject;
myTransform= transform;
// allow respawning from the start
canRespawn=true;
// save our accelMax value for later use, in case we need to
// change it to do AI catch up
originalAccelMax= accelMax;
// add default keyboard input if we don't already have one
if( default_input==null )
default_input= myGO.AddComponent<Keyboard_Input>();
// cache a reference to the player controller
myPlayerController= myGO.GetComponent<BasePlayerManager>();
// call base class init
myPlayerController.Init();
// with this simple vehicle code, we set the center of mass
// low to try to keep the car from toppling over
myBody.centerOfMass= new Vector3(0,-3.5f,0);
// see if we can find an engine sound source, if we need to
if( engineSoundSource==null )
{
engineSoundSource= myGO.GetComponent<AudioSource>();
}
AddRaceController();
// reset our lap counter
Search WWH ::




Custom Search