Spline mesh bad twisting bug

This image shows the problem:

I’ve tried changing default spline Up Vector, but it didn’t helped. In this example we can clearly see that the spline twists only when it’s facing near X or -X direction. Is there any workaround for this?

1 Like

Hey Slavq,

If this is a custom spline mesh, you can create a way to un-twist the spline in the opposite directions based on each point.

I would also take a look at this post to see if you can find any help suggestions or solutions as well.

Let me know if you have further questions or need additional assistance.

Thanks,

2 Likes

Thanks. In my case it’s procedural and generates in many different directions, depending on random seed.

The solution from the post that You have mentioned didn’t helped, but something very similar did: Instead of taking spline direction + rotating, I took spline Up Vector (‘Get Up Vector at Time’) and set it as Set Spline Up Dir when adding spline mesh component.
This fixed the twisting, but created a problem when spline is going up or down :

It’s like the roll is off, but I’ve tried to set roll manually to the spline roll at the time (or at 0), but nothing changed. It’s strange that is happens only if spline is going up or down…

Update: Another screenshot showing the problem:

2 Likes

It seems like you might now need to use the blend angle corrected normals for the rope material so your normals blend at the seams where they would connect.

Keep messing around with your blueprint and materials, as well as locating some other helpful solutions to see if you can get this worked out. You are on the right track and seem to have a good handle on the troubleshooting process. If you get completely stuck, let me know and I can assist you further.

Cheers,

2 Likes

I know this is an old post but my plugin is specifically designed to address this issue.

It offsets a second spline so that even when the spline is subdivided you won’t get any twisting.

3 Likes

The solution is actually really simple. You just need to “Set Spline Up Dir” from your “Add Spline Mesh Component’s” return value, set the default to X:0, Y:0, Z:1 and then promote this to a variable and expose it. Then when you run into an issue, just set the Up Dir to be a different value based on the rotation of the spline mesh. For example, if you rotate the spline so it’s going up in World Z, then you’ll need to set the Up Dir to X:0, Y:1 Z:0. This does limit you in that you can’t have one constant contiguous spline mesh that moves in every direction. For that, you would need to either fix the code yourself or purchase @RyanGadz 's plugin.

2 Likes

I found an even better Solution by Chris Murphy:
https://twitter.com/HighlySpammable/status/1245994732615942147

Copy and Paste the Construction Script code into whatever Engine Version you’re using:

3 Likes

Hi, I’ve check the code and try to implement it in c++, unfortunately the “SetSplineMeshRelativeRoll” function doesn’t exist. Do you know by any chance what’s inside?

I’ve applied Chris’s code and it appears to make no difference? Also tried this code (found on Reddit) and also no impact at all… Not sure what I’m missing here?

Chris’s code uses a “SetSplineMeshRelativeRoll” function, did you find what is inside?

Yes, just grab the uasset from his twitter link and you can see what he does.

1 Like

He has more than 11 000 posts on twitter lol.
Thanks anyway :slight_smile:

Lol, I thought you saw it above.

1 Like

My bad, I didn’t read carefully and thought it was the link of the blueprintUE page :sweat_smile:
thank you !

1 Like

yeah the blueprintUE page is a red herring without that function.

Frist of all…
I dunno why Epic Games still have not fixed their spline components and spline mesh components. Because there are some mathematical solutions for this problem which a very commonly used on other engines like Unity for example. I just simply do not understand why they give us parts to solve us this problem by our selfs. A pre-made tool will be very nice.

Secondly there’s a method called Parallel Transport and here’s a video about it:

And here’s a spline tool I made using this method which in most cases does not require you to jump around it and fix something manually (how it actually should work out of the box):

(it has some other features like spline decomposition for example - just ignore that it will take ages to me to explain how this work as well as it is exceeding the context of this thread)

I mean its not that simple as just do the stuff from the video. Sinse you need to calculate correct rotations for start and end of the spline mesh.

Here’s some screenshots that should help you to do the same… Screenshots are provided in the order how they are connected…
Here’s a parallel transport function from the video above:

Here’s how I use it:

Here’s how I calculate average UP vecrtor for each spline mesh:

Next I calculate right vectors (don’t remember already for what reason but it is used somehow to fix the rotation of spline mehes start and end):

Yeah after a while you will stop understanding your own code :smiley:
I guess I compensating the difference between spine right vector at end point and between spline meshes right vectors to somehow compensate the difference. As I said I already don’t remember all the details, I spend a lot of time debugging the vectors visually to see how I should fix them. And this is solution I found.

And here’s the angle compensation which I mentioned above:


Well… basically its just define the sign in order to compensate the angle in correct direction…

Start roll and end roll’s - are rolls from spline points which you can get from a spline. Base Rotation - is a parameter to rotate the whole spline uniformly.

Next you need to create a spline mesh and plug all the bullsh@t to it:

Start and end locations and tangents you can grab from the spline. Up Vector and Start End roll’s I already showed you how to calculate. This method works progressively from start to end. So you need to do it in the loop each time updating the transport vector.

As a start vector to transport you can grab 0 0 1 vector or default first point up vector. I hope it help everyone…

I mean this is what everybody wants on Unreal. So if someone from Epic Games reading this.
PLEASE finally solve your spline tools. Just make a default tool that has a decent quality and perfomance. It’s not hard! You just don’t want to solve this issuse because its not in your priority list. But people need this.

Now I guess its time for some Indian guy to make a tutorial on you tube from this xD Or maybe I my self do it at some point if some miracle will happen and I’ll stop being so lazy…
Eh… I don’t mind. I just hope everyone’s life become’s easier because of this post…

Have fun…