Problems with vertical loop on spline mesh

I am having some trouble making vertical loops for spline meshes. The basic problem is that spline meshes in Unreal Engine will twist 180 degrees if they are bent in a vertical loop. This is a problem that [has been solved before here][1], but I am having trouble implementing the solution I am unsure whether to attribute this to me not understanding it or if later updates have caused this solution to no longer work, and I hope someone in the community can help me find out what I’ve missed.

The other thread is a year old and marked as solved and I have not been able to contact the guy who solved it the last time, which is why I am opening a new thread. One difference between my blueprint and the one in the other thread is that I get the tangent at distance along spline instead of direction at distance along spline. Using distance no longer seems to work, but this might also be the reason why I am not seeing identical results to the other thread.

My setup for generating a spline mesh is very standard and work exellently for anything but vertical loops. Here is a screenshot of the construction script of the actor containing the spline and one showing the twisting that happens when entering a vertical loop:

Following the solution provided in the thread linked to above I have added a couple of extra node that rotates the up direction of each spline mesh so that it equals its normal, like so:

This works perfectly as long as all points are aligned along the same axis, but as soon as I move some of the spline points in the axis perpendicular to the main direction of the spline everything breaks down and all spline meshes are rotated incorrectly in relation to adjacent spline meshes.

I have been able to get the pieces to line up correctly by modifying the construction script so that I can manually change the start roll of each spline mesh segment, but is an inelegant and tedious solution for something it should be possible to automate.

Does anyone know what I might have missed in attempting to fix this problem? I am out of ideas on how to solve this so any help would be greatly appreciated.

1 Like

Did you find a solution?

Also interrested in if you found a good solution to do this in the construction script.

I’ll give it a try when i get home and let you know if i can figure it out.

I have been working on this for half a week. After many different attempts, I figured out how to get the correct roll for the spline mesh component. I am working in UE 4.13.1.

First, I use the get up vector at distance along spline node instead of rotating the tangent upward. I also get the up vector at the middle point of where I want to place the spline mesh.

Get Average Distance macro.

I use the rotation to get the roll relative to the new up vector of the Spline mesh component. You need the roll of both the start and end of the spline mesh. Also, the start and end roll for the spline mesh use radian instead of degrees so you have to convert it first.

The get relative roll at spline point function. I use the direction vectors since the get relative transform did not work for some reason. (as did many other things I tried)

And finally creating the spline mesh component.

This method also gives you the ability to roll your spline points and have the spline mesh follow that roll. So you can bank in turns or make corkscrews.

I hope that this helps you or anyone else with this problem.

1 Like

Can’t say i understand the math behind the unrotate part, but with your logic applied

without roll logic

On the other hand, your version doesn’t seem to produce these sudden twirls… seems it more spreading it out over a distance of the spline… So might actually be a better solution even though i don’t understand it fully.

I use it personally for a race track similar to the post at the top and the roll is needed to fix the issue he was having where the spline meshes miss-aligned when moving a spline point or adding yaw.

I unrotated the vectors to get them relative to the new up vector I use for the spline mesh and then get the roll from that.

To fix your issue you might want to try and divide the spline by more spline meshes. Or you might want to check if you have added roll to your spline points since this affects the roll of the spline meshes which may cause the twisting.

Also if you only want to make a vertical loop it is probably easier to just make a flat loop and then rotating it’s parent upwards.

What is the last variable in the 4th screenshot you set? with the two float inputs?

And where do you use that “…spline point” function?

Don’t really get your question. But here is the entire class I use, hope it helps.

“it is split over multiple posts since the image limit”

construction script

Again hope it helps

Don’t really get your question. But here is the entire class I use, hope it helps.

“it is split over multiple posts since the image limit”

AddTrackEllement Function

Again hope it helps

Additional tip: When edditing the spline becomes slow turn of Run Construction Script on Drag in the class settings.

1 Like

Thx. This helps.
But I have also another problem. I have a pawn which is driving along the spline but on a looping the pawn rotates in a false way. I also see the track numbers are false. The two should stand upside down on the other side. Can one fix that?

I have seen, you never set a value for the variable “Spacing”. I think it has a default value? But which?

The first image has the defaults on the right side.

instead of getting the rotation on tick and setting that as the pawns rotation. You will have to calculate the difference in up vector and use that to rotate the pawn.

I do something similar. This is how I calculate the roll and pitch. If you want the yaw you will need to calculate that using forward vector.

You can probably just use the make rot function since you don’t need to isolate pitch and roll.

Then when you have your rotation you can use AddActorLocalRotation.

Hope this helps.

I can t believe noone actually thanked lispink for this AWSOMENESS, and also that it s not marked as a completed answer - First it s extremelly well Scripted. 2nd it s a very smart approach of a hack. 3rd it s very generous. I came today to this problem myself. And went for a similar approach, but I would have never thought of unrotate vector (witch I dont understand the logic). Though I ve plugged the roll to the rotation of the spline point (degrees to rad) as an addition to the system so you can loop and bank at the same time.

@anonymous_user_07b2b30b, are u actually working on something ?

1 Like

Thank you lispink for solution!

This works perfect! Thank you for sharing

Does anyone happen to have a working version of this setup for 5.1? I know some people seemed to get this working back in 4.13, but I don’t even recognise some of the nodes being used for it (I am a noobie though)