Ejemplo n.º 1
0
    private void moveSmoothly()
    {
        Vector2 input = new Vector2(m_inputMove.x, m_inputMove.z);

        Vector3 targetVel = new Vector3(input.normalized.x * MoveSpeed, 0, input.normalized.y * MoveSpeed);

        if (!m_physics.OnGround() && !DecelerateInAir)
        {
            if (m_velocity.x > 0.1f && m_inputMove.x >= 0f)
            {
                targetVel.x = Mathf.Sign(m_velocity.x) * MoveSpeed;
            }
            else if (m_velocity.x < -0.1f && m_inputMove.x <= 0f)
            {
                targetVel.x = Mathf.Sign(m_velocity.x) * MoveSpeed;
            }
        }
        if (m_currentlySprinting)
        {
            m_velocity.x = Mathf.SmoothDamp(m_velocity.x, targetVel.x * m_sprintRatio, ref m_accelerationTimeX, SMOOTH_TIME);
        }
        else
        {
            m_velocity.x = Mathf.SmoothDamp(m_velocity.x, targetVel.x, ref m_accelerationTimeX, SMOOTH_TIME);
        }
        m_velocity.z = Mathf.SmoothDamp(m_velocity.z, targetVel.z, ref m_accelerationTimeZ, SMOOTH_TIME);
        m_physics.InputMove(m_velocity, m_inputMove);
    }
Ejemplo n.º 2
0
    private void moveSmoothly()
    {
        Vector2 input         = new Vector2(m_inputMove.x, m_inputMove.z);
        float   realMoveSpeed = MaxMoveSpeed;

        foreach (float f in m_modifierDuration.Values)
        {
            realMoveSpeed *= f;
        }
        Vector3 targetVel = new Vector3(input.normalized.x * realMoveSpeed, 0, input.normalized.y * realMoveSpeed);

        if (!m_physics.OnGround() && !DecelerateInAir)
        {
            if (m_velocity.x > 0.1f && m_inputMove.x >= 0f)
            {
                targetVel.x = Mathf.Sign(m_velocity.x) * realMoveSpeed;
            }
            else if (m_velocity.x < -0.1f && m_inputMove.x <= 0f)
            {
                targetVel.x = Mathf.Sign(m_velocity.x) * realMoveSpeed;
            }
        }
        if (m_currentlySprinting)
        {
            m_velocity.x = Mathf.SmoothDamp(m_velocity.x, targetVel.x * m_sprintRatio, ref m_accelerationTimeX, SMOOTH_TIME);
        }
        else
        {
            m_velocity.x = Mathf.SmoothDamp(m_velocity.x, targetVel.x, ref m_accelerationTimeX, SMOOTH_TIME);
        }
        m_velocity.z = Mathf.SmoothDamp(m_velocity.z, targetVel.z, ref m_accelerationTimeZ, SMOOTH_TIME);
        m_physics.InputMove(m_velocity, input);
    }