/// <summary> /// Reinit this vehicle. Reset to default state. /// Should be called when player restarts /// </summary> /// <param name="accelerate">true, if start speed of this vehicle must be 0</param> public void Reinit(bool accelerate) { playerRigidbody.isKinematic = true; // default values currentSpeed = accelerate ? 0 : DefaultSpeed; currentSideSpeed = accelerate ? 0 : DefaultSideSpeed; targetSpeed = currentSpeed; targetSideSpeed = currentSideSpeed; TravelledDistance = 0; OnDistanceChange?.Invoke(TravelledDistance); Health = MaxHealth; OnVehicleHealthChange?.Invoke(Health); // stop and remove existing particles engineSmoke.Stop(); engineFire.Stop(); engineSmoke.Clear(true); engineFire.Clear(true); SteeringWheel.Restart(); OnVehicleStart?.Invoke(); }
void ProcessPlayerDeath(GameScore score) { // stop the vehicle, if player died Brake(); SteeringWheel.Stop(); }