Beispiel #1
0
    private void TankUpdate()
    {
        if (!m_isGrounded || buffs.GetIsFrozen() || EatingProcessScript.getIfEating())
        {
            return;
        }
        //float v = Input.GetAxis("Vertical");
        //float h = Input.GetAxis("Horizontal");
        //if (scroll.distance.x == 0 || scroll.distance.y == 0) return;
        //Debug.Log(Input.GetAxis("Vertical"));
        float h = scroll.distance.x;
        float v = scroll.distance.y;

        //Debug.Log("x: " + h + "y: " + v);
        if (v < 0)
        {
            h = -h;
        }

        if (!button.firstPerson)
        {
            v = Input.acceleration.y;
            h = Input.acceleration.x;
        }

        bool walk = Input.GetKey(KeyCode.LeftShift);

        if (v < 0)
        {
            if (walk)
            {
                v *= m_backwardsWalkScale;
            }
            else
            {
                v *= m_backwardRunScale;
            }
        }
        else if (walk)
        {
            v *= m_walkScale;
        }

        m_currentV = Mathf.Lerp(m_currentV, v, Time.deltaTime * m_interpolation);
        m_currentH = Mathf.Lerp(m_currentH, h, Time.deltaTime * m_interpolation);

        if (button.firstPerson)
        {
            transform.position += transform.forward * m_currentV * m_moveSpeed * Time.deltaTime;
            transform.Rotate(0, m_currentH * m_turnSpeed * Time.deltaTime, 0);
        }
        else
        {
            transform.position += (new Vector3(h, 0, v)) * m_moveSpeed * Time.deltaTime;
            //transform.Rotate(0, m_currentH * m_turnSpeed * Time.deltaTime, 0);
            transform.LookAt(transform.position + (new Vector3(h, 0, v)));
        }

        m_animator.SetFloat("MoveSpeed", m_currentV);
        //Debug.Log(m_currentV);

        JumpingAndLanding();
    }