Пример #1
0
    private void Start()
    {
        Debug.Log(Mathr.InverseLerp(0.0f, 10.0f, 5.0f, INTERPOLATION.Linear));
        Debug.Log(Mathr.InverseLerp(0.0, 10.0, 5.0f, INTERPOLATION.Linear));

        Debug.Log(Mathr.Lerp(0.0, 10.0, 0.5f, INTERPOLATION.Linear));

        Debug.Log(Mathr.InverseLerp(Vector2.zero, new Vector2(10.0f, 10.0f), new Vector2(5.0f, 5.0f), INTERPOLATION.Linear));
    }
Пример #2
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.DownArrow))
        {
            Minus();
        }

        if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.RightArrow))
        {
            Plus();
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            Plus();
            Stop();
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            Active();
        }

        if (!m_work)
        {
            return;
        }

        m_cube.position = Mathr.Lerp(m_v0, m_v1, m_time, m_interpolation);

        if (m_time >= 1.0f)
        {
            if (m_auto)
            {
                Next();
            }
            else
            {
                m_work = false;
            }
        }

        m_time += (Time.deltaTime * m_velocity);

        if (m_time >= 1.0f)
        {
            m_time = 1.0f;
        }

        SetTime();
    }