How to properly segmentate a Spline Component

Hi, I’ve created an Actor Blueprint with a Spline as its Root Component and placed it into the world, then on Construction Script I set the location of both Initial and End Spline Points:

This leaves me with Point Index 0 and Point Index 1 from Start to Finish of the Spline Length - however, as the distance between these 2 points if very large, I need to divide the Spline with multiple Point Indexes, e.g. I need to segmentate the Spline from Point Index 0 to Point Index 50.

I notice I can use the Division node to make this happen, but I’ve been messing with it but don’t know how to properly set it up:

Much appreciated for any help with this.

Thanks.

That works perfectly!

However the initial problem still persists, I’m getting a weird stutter when the Camera is approaching the Final location:

I thought that by adding more spline points, it would smooth out the transition, but it must be caused by something else.

I’m using Ease In Out with Alpha on a Linear 0-1 Timeline to control the velocity of the camera transition:

I’ve tried changing the Tick Group of the 3 Actors (1st Pawn from Initial Location, Spline Actor and 2nd Pawn on End Location) but the issue persists.

Maybe I’m missing some Add Tick Prerequisite Actor? I can confirm that if using EventTick instead of a Timeline makes the stutter disappear.

edit: Is it feasible to clear/delete each Spline Point as the Initial Pawn passes through them?

  • Timeline + Ease do not mesh well - this would interpolate twice. In the best case scenario you’ll get inconsistent or hard to predict results. Worst case - other issues will manifest, depending what the resulting data is used for. Also, the blend exponent is set to 0 - I’m finding it difficult to imagine how the whole thing would look on a graph. Funky, for sure.

  • but most importantly - there seems to be a logic issue here. The spline is a part of this actor - it’s its root. When you move the actor, the spline also moves with it. So the whole thing keeps moving and we’re interpolating for the 3rd time as the spline’s end location keeps changing. That sounds like a little debugging nightmare. :ghost:


I may not fully understand what this is supposed to be used for - you might be after something uncanny.

Could you briefly describe what the end goal is. How is the feature supposed to work? At a glance it seems we’re attempting to move a camera actor along a spline. We start at the beginning and finish at the end. And we want the transition to be smooth and last X seconds.

What else am I missing?

Sorry I’ll try explain myself better:

  1. On BeginPlay, I possess Pawn1 which is set to location X.
  2. At the same time, Pawn2 is spawned on location Y.
  3. When both Pawns are spawned, a Spline_Blueprint Actor is spawned - Spline Points are created too using the code you shared, going from Initial Location X to End Location Y.
  4. On my MainMenu, clicking on New Game button will start the Timeline and SetActorLocation Ease transition.

The Alpha float from Timeline is linear and goes from 0 to 1 in 5 seconds - then the Ease In Out with Blend Exponent set to 8 to slow down the beginning and end transitions.

As it is, even if not using the Ease In Out and just a linear transition, it works as intended when the spline is not immensely huge.

Problem is that I’m working with extreme distances (more than 1,000,000 units from start to end locations).

From my observation, it seems like a problem of precision - the stutter starts happening when spline is bigger than ~1,000,000 units.

So I feel like I have 2 options:

  1. If I have e.g. 50 Spline Points, delete Spline Point 0 whenever Pawn1 passes by Spline Point 1 in World Space. This way the Spline Length would decrease and become more precise while approaching End location.
  2. Instead of using a Spline, use a LineTrace and take care of the SetActorLocation interp on EventTick - this seems to be a good solution, but I lose control of the transition time not being constant. (or is there a way to make the transition last for 5 seconds independent of distance while using EventTick?)

Moving a camera along a spline with just 2 spline points - 1 million units is very buttery smooth when I:

image

But, you must prepare the data upfront, you cannot resample data while the timeline is updating, you’ll run into the 2 bullet points I mentioned above. You can use Ease on top but that, sure, because who’s going to stop you - fiddling with bézier curves is not much fun.


Above, if this spline moves with this actor, you’re going to have a bad time. And that’s what I understood from the description.


From my observation, it seems like a problem of precision - the stutter starts happening when spline is bigger than ~1,000,000 units.

If you’re referring to the floating point errors, these work a bit differently. It’s not a about how large things are. It’s about how far from the world’s 0,0,0 they are.

If I try to perform a short trace from 5m uus to 5.1m uus - things will not work well even though the distance is a meagre 100.000 units. A spline that goes from 0,0,0 to 1.000.000 is fine. A spline that goes from 3m to 4m could be problematic. But that’s not what your video demonstrates in my humble opinion.

There is enough float precision to operate within 2.5km (2.5m uus) from the world centre in each direction. Above those values things may get hairy. But there’s also world origin shifting if you need to centre your world on a specific coordinate.

Subdividing a spline will not help here.


edit: do we need a spline to start with? Why not move it from A->B using just coordinates. You’d want a spline if there was a bendy path difficult to describe with math.

But that’s not what your video demonstrates in my humble opinion.

Yes, the video is cropped, only showing the final part of Ease Out when reaching final location.

I’m fiddling SetWorldOrigin when WorldLocation is to far from Current Camera Location - which changes when distance > 500,000u .

edit: do we need a spline to start with? Why not move it from A->B using just coordinates. You’d want a spline if there was a bendy path difficult to describe with math.

There are some bendy paths, but all of them are spherical, like so:

So I make a LineTrace to see if the path is obstructed, if not, then the trajectory is a straight line - If Pawn2 at the FinalLocation is obstructed by the sphere, then I manipulate the tangents.

I guess the best way to approach is to use a LineTrace running on EventTick instead of using Spline? It’s proving to be a real pain - even if I SetWorldOrigin to the FinalLocation, there’s still this weird stutter.

For you to have a better visualization of this issue, please create a new ThirdPersonCharacter Template project and add this to the ThirdPersonCharacter_BP:

Then create a new Actor Blueprint, add a Spline as root component and add this:

Now switch Point Index 0 X,Z locations from -10,000,000u to -1,000,000u to -100,00u, you’ll notice this stutter. How could we go around this?

bump

Did you ever find a solution for this?

bump