Exemple #1
0
    public void SetPositionsDots(Vector3 startMPos, Vector3 endMPos)
    {
        int pointsCount = (int)(Vector3.Distance(startMPos, endMPos) / _distanceBetweenPoints);

        Vector3 position   = Vector3.zero;
        int     checkValue = Mathf.Max(_pointsPool.ActiveItems.Count, pointsCount);

        for (int i = 0; i < checkValue; i++)
        {
            position = startMPos + (endMPos - startMPos).normalized * (_distanceBetweenPoints * (i + 1));
            if (i > _pointsPool.ActiveItems.Count - 1)
            {
                _pointsPool.Get(position);
            }
            else if (i < pointsCount)
            {
                _pointsPool.ActiveItems[i].transform.position = position;
            }
            else
            {
                _pointsPool.ReturnLastActive(_pointsPool.ActiveItems.Count - i);
                break;
            }
        }


        //for (int i = 0; i < _dotAmount; i++)
        //{
        //	Vector3 targetPos = Vector2.Lerp(startMPos, endMPos, i * _dotGap);
        //	_dotArray[i].transform.position = targetPos;
        //}
    }