Well lets say I have 5 Vector3’s and I want to sum their distance Together acording to player position along the path.
So for example I have a road that is 500 meters long and player has traveled the road 250 meters.
Any ideas?
Well lets say I have 5 Vector3’s and I want to sum their distance Together acording to player position along the path.
So for example I have a road that is 500 meters long and player has traveled the road 250 meters.
Any ideas?
Hi Ravel,
I’m tackling the same problems and found links to this document in the forum…
http://www.geometrictools.com/Documentation/MovingAlongCurveSpecifiedSpeed.pdf
If you figure it our maybe you can explain it to me
nvm, got the file open, and i think this goes way to much in depth of maths, i think it shouldnt be that hard, just a matter of adding small distances together i think? like distance1+distance2+distance3, only that in begining the distance is 0 to all of the lengths, because a spline is created from multiple lines, the thing that keeps me out of focus is how should I do this in the array, should I actually use index modifyers or multiple arrays…
I allready found the total length with an array function that sums up all the distances, resulting in total length, but now when i tryed to travel the length it didnt work that well.
If it’s just a bunch of straight line segments making up a path, it’s pretty easy - get sum of the distances between each adjacent pair. If you want to figure out how far along that path an object is, you do that up until the last of the points which they reached, and then add the distance they have traveled from that point towards the next.
If it’s an actual spline it’s quite different, and from memory you can only ever approximate the result (though the approximation can be so close it wouldn’t make much practical difference). Personally, if I were using a spline in a game and needed to be able to measure distance along it, I’d just break it into a series of straight line segments and use the above method.
Hello AngryPenguing, yes my spline is made out of lines, heres a image:
The yellow line is the rough waypoint line, the orange lien is generated spline wich is a bunch of lines actually, now how should I use the method you mentioned? Becaue I tryed something simmmilar and I get wrong results prety much every time, never got close to what the length actually is
The length is ~1500 units(meters) and usually I get the distance from the first point only, sometimes I get distances from every point and they sum up tomore than 6k so yeah thats ot right. Anyway On the image you see about 17 waypoints and 99 spline points. The points are in arrays/list obviously
so I have to work with loops.