Hello. I have a road mesh and a spline, both inside an actor blueprint. The spline is followed by an autonomous vehicle that the player sits in. Within the actor, the spline and the road line up perfectly - the spline goes down the exact centre of the lane all the way.
However, when this actor is placed in the world, the spline no longer lines up with the road where it curves. I’ve checked and double-checked that everything is lined up as far as the positions, etc. of all the objects (i.e. all set to zero) and I can’t see any reason for this. The spline appears to be a different shape when viewed in the world than it is in the actor.
I’ve attached screenshots to show the problem (you might want to zoom your browser in to see the difference).
This may look like a subtle difference but in-game it’s a lot more obvious - when the vehicle follows the spline it veers off first to one side then the other and it just doesn’t look or feel right to the player. There’s nothing I can do about that because the spline points and their handles are all correct.
It’s possible I’m just doing something wrong but it looks to me very much like a bug in the way splines are interpolated between the points.
Honestly I don’t see any difference in your screenshots, except the fact that the first one is slightly more zoomed in than the second one.
I would rather think of an issue (or some settings to be adjusted) in the code the car uses to follow the spline. Maybe it has a high tolerance to the distance from it, so it goes from one side to the other easily depending on starting position and on how the spline curves.
Did you write that car code yourself or is it something you bought on the marketplace?
Thanks for looking. Believe me, the white lines are not the same and the difference is definitely visible in the screenshots. As I say, you might need to zoom in though.
If you imagine travelling along the white line from left to right, you can see the line in the bottom image get closer to the right-hand edge of the lane, and then get further away, whereas in the top image it stays in the middle. It’s a difference of a good metre or so of transverse travel from where it should be.
I wrote the code myself. It works fine, which is to say it follows the spline as I’d expect it to. However, the spline is inexplicably distorted.
In answer to my own question, the culprit was the ‘Allow Discontinuous Spline’ option. The spline handle sizes accept different values if this is unticked but the values for one of the handles are ignored, so the spline is drawn as if the handles are symmetrical. Since I have asymmetrical handles, this meant the resulting spline was slightly distorted.
Ticking this box and has resolved the issue.
By the way, I have to multiply the handle sizes by exactly 4 as well, but I’d already worked this out before posting this issue.