Help getting around Spline distance precision issues

Hey everyone.

I could use some help dealing with spline distance precision issues. From my research, it appears that using distance based functions for the spline component like Get Location at Distance Along Spline result in precision issues.

Video example In this video, notice how the prior and following rail cars jitter forwards and backwards. This is a precision issue caused when tangents are used and spline point types are not set to linear. When the point types are linear, there is no jittering.

Okay. So… what can I do about this?

:green_circle: SOLUTION :green_circle:

From my research, it appears that using distance based functions for the spline component like Get Location at Distance Along Spline result in precision issues.

A lot of video game stuff is smoke & mirrors + good-enough approximation, sure. I’ve never ever experienced anything like this with splines, though. Might be wrong but I’d blame the movement method / something else than sheer lack of precision. Not at this scale and scope.

Could you replicate it with a single car and / or explain the movement method?

1 Like

Sure thing, I’ll do my best. I’ll focus on showing why this is an issue with just one rail car instead of a train of rail cars to make it simple.

This is the tick function.

ApplyWheels is not relevant since it only effects some scene components and doesn’t touch the Actor’s position.
IncrementPosition just increases the cached distance float using a speed and world delta seconds.

The only func to pay attention to is ApplyPosition. But inside, it’s extremely simple. Most of what you’re seeing is just some debug stuff set up for logging. The core of it is just getting the location from the spline using distance and then setting actor location and rotation. That’s it.

So let’s look at the raw data.
image

I understand in theory that the rate of change shouldn’t be totally constant (to account for framerate), but there is a discrepancy between the units of distance changed vs real world v3 change. It’s small, but it adds up I feel. I think that’s the source of the jitter.

I hope that added more useful context. I’d be happy to clarify more if you’d like

How does Correct Rotator work with the pivot of the mesh. Where is the pivot?

I think that’s the source of the jitter.

I don’t buy it (yet!), your jitter is in 10s uus, not .01.


Here’s what I’m getting at: in order to figure it out, we’d need a reliable way of replicating it. All I get is a buttery smooth (on my end - not in the compressed anim) progress under regular circumstances:

So I must question the irregular. I also tested the above at 1 million uus from world origin. Also made the spline a couple million uus long - here you can tell the interpolation is lacking when you spread spline points over great distances. The movement is still smooth though, you just can feel the angles.

1 Like

Oh right.

The pivot is the center of the mesh at the bottom.

image

Correct Rotator flattens the Z and will rotate it 180 if the train is going in reverse (Direction is 1 or -1). Although, the Direction shouldn’t affect anything here since in the sample I tested Direction was 1.

Finally, I ran the test once more, but this time, I had the spline’s points set to linear. I believe having a tangent causes greater inaccuracies. This was the result:
image

I would be more then happy to be wrong about this! XD

Run it without the rotator. Does it jitter?

Could you try the test you did once more, but this time, have another cube that is ahead and one cube that is before? Then, place the character so that it stands on one of the traveling cubes so the camera is synced to the cube. Do the prior and following cubes still appear smooth?

Also, thank you so much for your help!

I’ll try

Tried without the rotator macro. No change. Once again, I was able to visibly observe the jittery motion when I stood on the ramp of one rail car and looked at the prior/next cars. When the spline was linear, it moved perfectly smooth. When I added back in the tangent/curve point types, it reintroduced the jitter.

I think it’s definitely something that’s harder to observe when your player character isn’t standing on top of one of the moving objects.

So, there’s no jitter if you do no board the train?

There may be something there, but that’d be an issue with the CMC perhaps? I wonder if the observed result is due to the inconsistency of spline point distribution. You could try rewriting it using this instead:

image

Here’s the gist:

1 Like

I believe it’s still visible - but it’s much harder to observe/quantify when not aboard. It’s certainly harder to observe. When I run to match the speed of the train, the jitters become easy to spot.

1 Like

Oh! Sorry. I missed your edit before I responded. I’ll give that a try! Im going to bed soon, but I’ll try some of your ideas tomorrow. Thank you for your help!

1 Like

See if this method helps, at least you’ll get even distribution and can account for frame-time:


Project link to quickly test it on your end:

Since we can't really have this happing...

image

1 Like

Thanks so much for sending that project link over. I loaded into that environment and tweaked some values, and I’m able to see that jittering in your example.

This video was recorded with a spline duration of 5, Speed of .35, and spacing of 0.1. Although, you can achieve these results without changing the spline duration but just reducing the spacing. I know the jitters may look minor, but they add up when the scale is large and you’re dealing with train-sized objects.

Here is the test once again, but all the point types are linear instead of curved. No jitter.

Finally, here it is one last time with increased point density. I’d argue the jitter is basically invisible at this point.

I think my takeaway is that the jitter is most noticeable when

  1. Spline runners are near each other
  2. The player is traveling at the same speed as another spline runner
  3. Spline points are not linear
  4. Non-linear spline points are separated by large distances. Increasing point density seems to improve accuracy

What do you think? Do you think I got this right?

They only get jiggly when you ride them, right?

And when you match the speed. It’s hard to perceive the jitter when your camera doesn’t match the average speed of the spline runners

See if cranking this up on the spline helps at all:

image

1 Like

WAIT! What is this magical slider? I tried turning it up all the way to 100, to the max, and now everything looks totally smooth! What’s going on here? This is great!!

1 Like