GoSpline.getPointOnPath C# (CSharp) Метод

getPointOnPath() публичный Метод

returns the point that corresponds to the given t where t >= 0 and t <= 1 making sure that the path is traversed at a constant speed.
public getPointOnPath ( float t ) : Vector3
t float
Результат Vector3
    public Vector3 getPointOnPath( float t )
    {
        // if the path is closed, we will allow t to wrap. if is not we need to clamp t
        if( t < 0 || t > 1 )
        {
            if( isClosed )
            {
                if( t < 0 )
                    t += 1;
                else
                    t -= 1;
            }
            else
            {
                t = Mathf.Clamp01( t );
            }
        }

        return _solver.getPointOnPath( t );
    }

Usage Example

    public override void tick(float totalElapsedTime)
    {
        float   t      = _easeFunction(totalElapsedTime, 0f, 1f, _ownerTween.duration);
        Vector3 vector = _path.getPointOnPath(t);

        if (_isRelative)
        {
            vector += _startValue;
        }
        switch (_lookAtType)
        {
        case GoLookAtType.NextPathNode:
            _smoothedRotation.smoothValue = ((!vector.Equals(_target.position)) ? Quaternion.LookRotation(vector - _target.position) : Quaternion.identity);
            _target.rotation = _smoothedRotation.smoothValue;
            break;

        case GoLookAtType.TargetTransform:
            _target.LookAt(_lookTarget, Vector3.up);
            break;
        }
        if (_useLocalPosition)
        {
            _target.localPosition = vector;
        }
        else
        {
            _target.position = vector;
        }
    }
All Usage Examples Of GoSpline::getPointOnPath