Esempio n. 1
0
    // Update is called once per frame
    void FixedUpdate()
    {
        CurrentSpeed = 2 * Mathf.PI * FL.radius * FL.rpm * 60 / 1000;
        float translations = Input.GetAxis("Vertical") * MaxTorque;
        float Rotations    = Input.GetAxis("Horizontal") * MaxSteering;
        var   Brake        = Input.GetKey(KeyCode.Space);
        var   Nitro        = Input.GetKey(KeyCode.LeftShift);

        if (!Brake && !Nitro && CurrentSpeed <= MaxSpeed)
        {
            RL.motorTorque = translations;
            RR.motorTorque = translations;
            RL.brakeTorque = 0;
            RR.brakeTorque = 0;
            BackLight.DisableKeyword("_EMISSION");
            foreach (var Nitros in Nitrox)
            {
                Nitros.Stop();
            }
        }

        if (Nitro && CurrentSpeed <= MaxSpeed)
        {
            RL.motorTorque = translations + NitroTorque;
            RR.motorTorque = translations + NitroTorque;
            foreach (var Nitros in Nitrox)
            {
                Nitros.Play();
            }
        }

        if (CurrentSpeed >= MaxSpeed)
        {
            RL.motorTorque = 0;
            RR.motorTorque = 0;
        }

        FL.steerAngle = Rotations;
        FR.steerAngle = Rotations;

        if (Brake)
        {
            BackLight.EnableKeyword("_EMISSION");
            RL.brakeTorque = MaxBrake;
            RR.brakeTorque = MaxBrake;
            RR.motorTorque = 0;
            RL.motorTorque = 0;
        }

        speedVec      = ((transform.position - startPosition) / Time.deltaTime);
        speed         = (int)(speedVec.magnitude * 3.6f);
        startPosition = transform.position;
    }
Esempio n. 2
0
 public static void DeleteNitro(PowerUp n)
 => Nitros.Remove(n.transform);
Esempio n. 3
0
 private void SpawnNitroAt(Vector3 pos)
 => Nitros.Add(Instantiate(nitro, GetFixedPosition(pos, 1.0f), Quaternion.Euler(0, pos.y, 0)));