//set the motor speed that makes the vehicle move private void SetMotorSpeed() { if (speedControlVar > 0) { audioControl.playAudios("forward"); speed = speed < 0 ? speed + (float)((3.6 * 200 * 2) / (2f * 9.55f)) : speed < tyreAchievableSpeed["tyre_" + (currentTyreNum + 1)] ? speed + (float)((3.6 * 25 * 2) / (2f * 9.55f)) : tyreAchievableSpeed["tyre_" + (currentTyreNum + 1)]; HealthControl(); HideMessage(); } else if (speedControlVar < 0) { audioControl.playAudios("backward"); speed = speed > 0 ? speed - (float)((3.6 * 200 * 2) / (2f * 9.55f)) : speed > -1500 ? speed - (float)((3.6 * 25 * 2) / (2f * 9.55f)) : -1500; HealthControl(); HideMessage(); } else { speed = speed > 100 ? speed - (float)((3.6 * 50 * 2) / (2f * 9.55f)) : speed < -100 ? speed + (float)((3.6 * 50 * 2) / (2f * 9.55f)) : 0; audioControl.StopAudio(); } wheelMotor.motorSpeed = speed; wheelJoint.motor = wheelMotor; GameObject.Find("Speed").GetComponent <Text>().text = "" + speed; }
private void OnCollisionEnter2D(Collision2D collision) { //destry and play audio if vehicle somesaults if (collision.collider.tag == "LandPlatform" && gameObject.tag == "KillerBIrd") { WheelController.hasCrashed = true; frontWheel.enabled = false; backWheel.enabled = false; audioControl.playAudios("crash"); ShowRestartBtn(); } else if (collision.collider.tag == "LandPlatform") { audioControl.playAudios("crash"); } }