Ejemplo n.º 1
0
    void FixedUpdate()
    {
        if (m_engineOn)
        {
            float speed    = m_speedCrank.GetValue();
            float steering = m_steeringValve.GetRotation();
            float pitch    = m_pitchCrank.GetValue(); //needs remapped
            pitch = pitch * 2 - 1;                    // -1 and 1

            //m_ship.transform.Rotate(Vector3.up, steering * m_steeringAmount, Space.Self);//steer
            m_ship.transform.Rotate(Vector3.right, pitch * m_pitchingAmount, Space.Self);//pitch

            m_rb.AddForce(m_ship.transform.forward * m_speed * speed);
            m_rb.AddTorque(m_rb.transform.up * steering * m_steeringAmount, ForceMode.Force);

            m_fuel -= m_fuelConsumptionRate * Time.deltaTime;
            m_fuelTank.SetValue(100 * (m_fuel / m_startingFuel));

            if (m_fuel <= 0)
            {
                FindObjectOfType <EndOfLevelTrigger>().GameOver();
            }
        }
    }