public void StartCar() { // I usually alter the center of mass to make the car more stable. I'ts less likely to flip this way. //rigidbody.centerOfMass += Vector3(0, -1, .25); GetComponent<Rigidbody>().centerOfMass = new Vector3(GetComponent<Rigidbody>().centerOfMass.x, GetComponent<Rigidbody>().centerOfMass.y -1, GetComponent<Rigidbody>().centerOfMass.z + 0.25f); muzzleyOn = false; rotacaoAuto = 28; carState = BUMPERCAR.NORMAL; powerUpTimeInitial = 16; multiplicadorDeVelocidade = 1; carenagemMat = carenagem.GetComponent<Renderer>().material; borrachaMat = borrachao.GetComponent<Renderer>().material; volanteMat = volante.GetComponent<Renderer>().material; AtivarHudPowerUp(false); if (steerside != STEERSIDE.IA) { steerside = STEERSIDE.FRENTE; } }
void InputPlayer() { // finally, apply the values to the wheels. The torque applied is divided by the current gear, and // multiplied by the user input variable. FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * aceleracaoRoda; // the steer angle is an arbitrary value multiplied by the user input. // if (rotacaoRoda < 0.1f && rotacaoRoda > -0.1f) // { // if (FrontLeftWheel.steerAngle <= 0.1f && FrontLeftWheel.steerAngle >= -0.1f) // { // FrontLeftWheel.steerAngle = 0; // //volante.transform.Rotate(0,0,-3); // print("Setando algulo da roda para 0"); // } // // if (FrontLeftWheel.steerAngle > 0.1f ) // { // FrontLeftWheel.steerAngle -= 3; // volante.transform.Rotate(0,0,-3); // } // else if (FrontLeftWheel.steerAngle < -0.1f) // { // FrontLeftWheel.steerAngle += 3; // volante.transform.Rotate(0,0,+3); // } // } // else // { // FrontLeftWheel.steerAngle += rotacaoRoda; // volante.transform.Rotate(0,0,rotacaoRoda); // } if (steerside != STEERSIDE.IA) { if (rotacaoRoda == -1 && FrontLeftWheel.steerAngle > 0) { //volante.transform.Rotate(0, 0, FrontLeftWheel.steerAngle); FrontLeftWheel.steerAngle = 0; } else if (rotacaoRoda == 1 && FrontLeftWheel.steerAngle < 0) { //steerside = STEERSIDE.DIREITA; //volante.transform.Rotate(0, 0, FrontLeftWheel.steerAngle); FrontLeftWheel.steerAngle = 0; } //if (FrontLeftWheel.steerAngle == 0) // steerside = STEERSIDE.FRENTE; } switch (steerside) { case STEERSIDE.ESQUERDA: if (rotacaoRoda < 0.1f && rotacaoRoda > -0.1f) { if (FrontLeftWheel.steerAngle < -0.2f) { if (FrontLeftWheel.steerAngle <= -rotacaoAuto) { FrontLeftWheel.steerAngle += rotacaoAuto; volante.transform.Rotate(0,0,+rotacaoAuto); } else { FrontLeftWheel.steerAngle = 0; volante.transform.Rotate(0,0,+FrontLeftWheel.steerAngle); } } else { volante.transform.Rotate(0, 0, FrontLeftWheel.steerAngle); FrontLeftWheel.steerAngle = 0; steerside = STEERSIDE.FRENTE; } } else if (FrontLeftWheel.steerAngle > -30f) { FrontLeftWheel.steerAngle += rotacaoRoda; volante.transform.Rotate(0,0,rotacaoRoda); } break; case STEERSIDE.DIREITA: if (rotacaoRoda < 0.1f && rotacaoRoda > -0.1f) { /*if (FrontLeftWheel.steerAngle < 0) { volante.transform.Rotate(0, 0, FrontLeftWheel.steerAngle); FrontLeftWheel.steerAngle = 0; steerside = STEERSIDE.FRENTE; } else */if (FrontLeftWheel.steerAngle > 0.2f) { if (FrontLeftWheel.steerAngle >= rotacaoAuto) { FrontLeftWheel.steerAngle -= rotacaoAuto; volante.transform.Rotate(0,0,-rotacaoAuto); } else { FrontLeftWheel.steerAngle = 0; volante.transform.Rotate(0,0,-FrontLeftWheel.steerAngle); } } else { volante.transform.Rotate(0, 0, FrontLeftWheel.steerAngle); FrontLeftWheel.steerAngle = 0; steerside = STEERSIDE.FRENTE; } } else if (FrontLeftWheel.steerAngle < 30f) { FrontLeftWheel.steerAngle += rotacaoRoda; volante.transform.Rotate(0,0,rotacaoRoda); } break; case STEERSIDE.FRENTE: FrontLeftWheel.steerAngle += rotacaoRoda; volante.transform.Rotate(0,0,rotacaoRoda); break; case STEERSIDE.IA: FrontLeftWheel.steerAngle += rotacaoRoda; volante.transform.Rotate(0,0,rotacaoRoda); break; } if (steerside != STEERSIDE.IA) { if (rotacaoRoda == -1) { steerside = STEERSIDE.ESQUERDA; } else if (rotacaoRoda == 1) { steerside = STEERSIDE.DIREITA; } if (FrontLeftWheel.steerAngle == 0) steerside = STEERSIDE.FRENTE; } // if (steerside != STEERSIDE.IA) // { // if (FrontLeftWheel.steerAngle < -0.2f) // steerside = STEERSIDE.ESQUERDA; // else if (FrontLeftWheel.steerAngle > 0.2f) // steerside = STEERSIDE.DIREITA; // if (FrontLeftWheel.steerAngle == 0) // steerside = STEERSIDE.FRENTE; // } // if (FrontLeftWheel.steerAngle == 0) // steerside = STEERSIDE.FRENTE; // else if (FrontLeftWheel.steerAngle < 0) // steerside = STEERSIDE.ESQUERDA; // else if (FrontLeftWheel.steerAngle > 0) // steerside = STEERSIDE.DIREITA; }