I’ve been having unexpected results with Get Location at Distance Along Spline so I made a simple example to help figure this out.
I have a very simple spline with two points – (0,0,0) and (10000,0,0). Just a straight line on the X axis.
At some point during runtime I need to get the location at a certain distance. This should be pretty easy since it is just one axis – a distance of 50
should be a location of (50,0,0)
, right? A distance of 9,999
should be a location of (9999,0,0)
.
But it isn’t.
In the debugger I can see that it is passing a distance of 52.061588
. The resulting location is (X=10.279886, Y=0.000000, Z=0.000000)
. Not even close to what I’m expecting.
The next time this function gets called it passes a distance of 120.152600
and the location returned is (X=53.692993, Y=0.000000, Z=0.000000)
Am I not understanding how splines work, or is something else going on? This is a pretty straightforward example and I can’t begin to figure out how Unreal is calculating these locations.
Edit:
For some additional testing I made a small example and took screenshots here:
The basic gist is that there is a spline with a point at (0,0,0) and (10000,0,0). All tangents are zeroed out, no scale, no rotation.
I use Get Location At Distance Along Spline to draw Debug Points at 100 unit intervals. So draw a Debug Point at distance 0, 100, 200, 300, etc.
The result is points that are not equally spaced at all. The most obvious is near the beginning and end of the spline, but the spacing throughout is inconsistent.