Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- float currentLength = 0;
- float midPointI = 0;
- int segmentNum = 0;
- for (segmentNum = 0; segmentNum < routeData.Count; ++segmentNum)
- {
- float previousLength = currentLength;
- Vector3 pointA = routeData[segmentNum];
- Vector3 pointB = routeData[segmentNum % routeData.Count];
- Vector3 segmentDelta = pointB - pointA;
- float addLength = segmentDelta.magnitude;
- currentLength += addLength;
- if ((currentLength/routeLength) > i)
- {
- // the i point lies between these two!
- startPoint = pointA;
- endPoint = pointB;
- midPointI = (i - (previousLength / routeLength)) / (addLength / routeLength);
- break;
- }
- }
- Vector3 routePointPosition = Vector3.Lerp(startPoint, endPoint, midPointI);
Advertisement
Add Comment
Please, Sign In to add comment