Exemple #1
0
    // Update is called once per frame
    private void Update()
    {
        // If current position is close enough to lerp position
        // Then stop lerping to save on memory
        if (GlobalController.CloseTo(_rectTransform.position.x, _lerpPosition.x, 0.01f) &&
            GlobalController.CloseTo(_rectTransform.position.y, _lerpPosition.y, 0.01f))
        {
            _isLerping = false;
        }

        // If is lerping then lerp to position
        if (_isLerping)
        {
            _rectTransform.anchoredPosition =
                Vector2.Lerp(_rectTransform.anchoredPosition, _lerpPosition, InterpolationRatio);
        }

        Transform transform1 = transform;

        transform.right = Vector2.Lerp(transform1.right, _lookTarget.transform.position - transform1.position,
                                       InterpolationRatio);
    }