Graphics Reference
In-Depth Information
[System.NonSerialized]
public Keyboard_Input default_input;
public AudioSource engineSoundSource;
public virtual void Start ()
{
Init ();
}
public virtual void Init ()
{
// cache the usual suspects
myBody= rigidbody;
myGO= gameObject;
myTransform= transform;
// add default keyboard input
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,-4f,0);
// see if we can find an engine sound source, if we need to
if( engineSoundSource==null )
{
engineSoundSource= myGO.GetComponent<AudioSource>();
}
}
public void SetUserInput( bool setInput )
{
canControl= setInput;
}
public void SetLock(bool lockState)
{
isLocked = lockState;
}
public virtual void LateUpdate()
{
// we check for input in LateUpdate because Unity recommends
// this
if(canControl)
GetInput();
// update the audio
UpdateEngineAudio();
}
Search WWH ::




Custom Search