Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // start & end indices in routedata
- float iLength = 0;
- int startPointIndex = 0;
- int endPointIndex = 0;
- float midPointI = 0;
- while (iLength < routeLength * i)
- {
- Vector3 pos = routeData[startPointIndex];
- Vector3 npos = routeData[(startPointIndex + 1) % routeData.Count];
- float addLength = (pos - npos).magnitude;
- float prevLength = iLength;
- iLength += addLength;
- if (iLength >= routeLength * i)
- {
- endPointIndex = (startPointIndex + 1) % routeData.Count;
- // t1
- midPointI = (i - (prevLength / routeLength)) / (addLength / routeLength);
- }
- else
- {
- startPointIndex++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment