# Help getting around Spline distance precision issues

**URL:** <https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586>\
**Category:** Blueprint\
**Tags:** unreal-engine, Spline, Blueprint\
**Created:** [March 21, 2024, 5:56am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586 "2024-03-21T05:56:54Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 5:56am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/1 "2024-03-21T05:56:54Z")

</div>

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](https://youtu.be/XpSM6MLvw9U) 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?

🟢 SOLUTION 🟢

> [@Help getting around Spline distance precision issues](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/17):
>
> See if cranking this up on the spline helps at all: [image]

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 21, 2024, 7:57am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/2 "2024-03-21T07:57:44Z")

</div>

> [@JustJunuh](#):
>
> This is a precision issue caused when tangents

> 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?

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 8:25am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/3 "2024-03-21T08:25:23Z")

</div>

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/9/6/196a635c1531bb75c064fd44b86e4e35035347a0.png)

**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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/a/8/1a8499f890adcef46573cc2e59046eeaf15b0aa9.png)

So let’s look at the raw data.  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/9/449bfdf15044b2c518a696222d7cfe305ccb84d2.png)

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 21, 2024, 8:38am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/4 "2024-03-21T08:38:34Z")

</div>

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:

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/6/e/06efd449a539b4ee6734c708cfc917448aec5eb3.png)

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.

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 8:51am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/5 "2024-03-21T08:51:35Z")

</div>

Oh right.

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/d/d/1dd1a50686d0f4308d0e64db11e7b8a6163d774d.jpeg)

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/d/4/7d4a6fba8eb7b814f6d3c6eb89d47e055e9a55b1.png)

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/e/9/0e9643bfb52afe17294d9e990b2b31c986173565.png)

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 21, 2024, 8:52am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/6 "2024-03-21T08:52:58Z")

</div>

Run it without the rotator. Does it jitter?

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 8:53am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/7 "2024-03-21T08:53:35Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 8:54am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/8 "2024-03-21T08:54:25Z")

</div>

I’ll try

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 8:59am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/9 "2024-03-21T08:59:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 21, 2024, 9:00am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/10 "2024-03-21T09:00:57Z")

</div>

> [@JustJunuh](#):
>
> when I stood on the ramp of one rail car and looked at the prior/next cars.

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

> [@JustJunuh](#):
>
> place the character so that it stands on one of the traveling cubes so the camera is synced to the cube

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/9/b/99bceb8413ec0a582d76e5e7553fb1953a5aead6.png)

Here’s the gist:

> [@Actors on spline with irregular spacing](https://forums.unrealengine.com/t/actors-on-spline-with-irregular-spacing/677071/4):
>
> Play with distribution using spline duration instead: [image] The results without: And with Constant Velocity: Perhaps that’s enough.

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 9:07am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/11 "2024-03-21T09:07:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 9:14am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/12 "2024-03-21T09:14:03Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 21, 2024, 9:19am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/13 "2024-03-21T09:19:14Z")

</div>

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

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/8/7/687c46e8abb1129f857d42a94b267f07c844d799.png)

* * *

Project link to quickly test it on your end:

> **[thePainTrain.zip](https://drive.google.com/file/d/1-osmXP3jNnU_dKSh5sJq3AZgnkgK922w/view?usp=drive_link)**
>
> Google Drive file.

> **Since we can't really have this happing...**
>
> ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/2/4/e24a7a8012f33139169ac00de8bb58ac27ff32ea.jpeg)

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 21, 2024, 9:35pm UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/14 "2024-03-21T21:35:39Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 22, 2024, 7:05am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/15 "2024-03-22T07:05:57Z")

</div>

They only get jiggly when you ride them, right?

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 22, 2024, 9:04am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/16 "2024-03-22T09:04:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Everynone](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/everynone/32/1135017_2.png) [@Everynone](https://forums.unrealengine.com/u/Everynone)\
**Post date:** [March 22, 2024, 9:06am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/17 "2024-03-22T09:06:48Z")

</div>

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

![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/1/1/c11887f72c37515ed6357d265208f06d686cf981.png)

---

<div class="post-metadata">

**Author:** ![JustJunuh](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/justjunuh/32/1191727_2.png) [@JustJunuh](https://forums.unrealengine.com/u/JustJunuh)\
**Post date:** [March 22, 2024, 9:13am UTC](https://forums.unrealengine.com/t/help-getting-around-spline-distance-precision-issues/1764586/18 "2024-03-22T09:13:09Z")

</div>

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!!
