示例#1
0
    private void ApplyPath()
    {
        if (MovePath == null)
            return;

        float segmentDistance;
        int whichSegment = MovePath.GetSegmentIndex(mDistancePassed, out segmentDistance);
        transform.position = MovePath.GetSegmentPosition(whichSegment, segmentDistance);

        float t = Mathf.Clamp01(mDistancePassed/MovePath.GetArcLength());
        float angleRad = ZRotationStart + t*(ZRotationEnd - ZRotationStart);
        Vector3 angles = new Vector3(0, 0, angleRad);
        transform.eulerAngles = angles;
    }
示例#2
0
    public Vector3 GetCurrentPosition()
    {
        if (!HasPosition())
        {
            return(Vector3.zero);
        }

        float segmentDistance;
        int   whichSegment = mSpline.GetSegmentIndex(mCurrentDistance, out segmentDistance);

        Vector3 result = mSpline.GetSegmentPosition(whichSegment, segmentDistance);

        result.z += OffsetZ;
        return(result);
    }