void Start() { vehicle = GetComponent <PlayerVehicle>(); vehicleAudio = GetComponents <AudioSource>(); vehicle.OnVehicleCollision += CollideVehicle; vehicle.OnSteering += UpdateSteeringAudio; vehicle.OnVehicleHealthChange += ProcessVehicleBreak; vehicle.OnVehicleStart += StartEngineAudio; GameController.OnPlayerDeath += ProcessPlayerDeath; StartEngineAudio(); Debug.Assert(vehicleAudio.Length >= 3, "Must 3 audio sources", this); }
/// <summary> /// Init player, must be called before 'Start' /// </summary> public void Init() { MainCamera = GetComponentInChildren <Camera>(); // player must be faced to world forward transform.forward = Vector3.forward; // init vehicle Vehicle = GetComponentInChildren <PlayerVehicle>(true); Debug.Assert(Vehicle != null, "There must be a 'PlayerVehicle' as child object", this); Vehicle.Init(this); steeringWheel = Vehicle.SteeringWheel; // init weapons weaponsController = GetComponentInChildren <WeaponsController>(); weaponsController.SetOwner(this); SignToEvents(); }
public void SetVehicle(PlayerVehicle vehicle) { this.vehicle = vehicle; }