Esempio n. 1
0
        private void Update()
        {
            //If I am driving the TEx
            if (m_PV.IsMine)
            {
                //I set the animation values
                SyncAnimations();
            }

            //Animate the wheels
            WheelAnimations();

            //If Motor is On, Play relevant Sounds
            if (m_MotorOn)
            {
                float speedChange = m_CurrentSpeed - m_PreviousSpeed;
                float percChange  = speedChange / m_CurrentSpeed;

                m_MotorSound.AdjustPitch(percChange, m_MinMotorPitch, m_MaxMotorPitch);

                m_PreviousSpeed = m_CurrentSpeed;

                //Try play sound for each Wheel
                EnumerateWheelSounds();
            }

            //Display current speed in km/h
            m_HUD.text = Mathf.Round(m_CurrentSpeed * 3.6f) + " KM/H"; // 1 m/s is 3.6 km/h
            if (Vector3.Dot(m_RB.velocity, this.transform.forward) >= 0f)
            {
                float p = m_CurrentSpeed / m_MaxSpeedForUI;
                m_BackwardsBars.fillAmount = 0f;
                m_ForwardBars.fillAmount   = p;
            }
            else
            {
                float p = m_CurrentSpeed / m_MaxSpeedForUI;
                m_BackwardsBars.fillAmount = p;
                m_ForwardBars.fillAmount   = 0f;
            }
        }