Splines deform incorrectly

The new spline components are a huge step up but loops still doesn’t work.

Edit: repro; create an empty actor BP, add spline, draw a loop, check “closed loop”, try to rotate the handles.

This is the same spline with the scale indicators left as is, and then rotated inward.
74712-74713-
Opening the loop doesn’t help, and fact is however I try to rotate the points to have them flow nicely I keep getting heaps of wacky squashing and twisting;

In these two last pics, note that even the two segments that look kind of normal are also deforming. One segment is bulging in and the next bulges out slightly. Compare with the first pic that is completely straight, even if it has the hard twists that come with it.

Splines don’t mathematically have a twist, so the twist is implemented through spline-interpolating components of the quaternion. So full 180 twist gives us interpolation between (1,0,0,0) and (0,1,0,0). I’m not sure that the way spline interpolation and tangents work is mathematically valid to apply to quaternions.

Splines use CIM_Auto mode for the quaternions, while they should at least use CIM_Linear (it’s still not valid way of interpolating quaternions, but it wouldn’t create weirdness due to ‘quaternion tangents’). Or maybe an option to select either of them.

As a temporary workaround, approximate your curve with 16+ points instead of just four.

More crazyness when trying to add points

Thanks for the input. I’ve added a couple pictures of what happens when I add more points, getting it to work is very wobbly.

Hopefully a dev will see this and give some feedback.

Hi bzxo,

Could you also include a screenshot of the Spline components Details panel?

Hi TJ,
all defaults apart from visualize scale and visualize scale width, in an otherwise empty blueprint.

Hi bzxo,

Black Phoenix is correct. The way spline work in the editor are a bit limiting right now.

If you are trying to get a clean loop without any twist, you can set the Spline Up Direction to 0,0,0. Will that work for you? If not, what exactly are you trying to accomplish?

Hi TJ,
that would kinda destroy the purpose of having handles since you wouldn’t be able to twist the spline anymore.

I’m making a roadgen for rollercoaster type tracks and would like to be able to include loops without splitting the spline up into sections.

Is there a way to get working splines by extending the spline class?

Adding this functionality is something that we have logged in our system and we hope to work on soon.

Right now the best way to approach this in blueprints would be to build the spline mesh and alter the tangents entirely in the Construction Script or Event Graph. Using math you would need to calculate the tangents based off of the length between spline points.

If you are familiar with it, you could have even more control if you use code instead.

I guess it’s time to get into code then :slight_smile: I’d still need to use the information from the spline though, since auto bezier based on point locations wouldn’t be tweakable. Any pointers for getting started, programming wise? Do I need to use the code version of the engine or can I extend the spline class?

I don’t believe there is an official code tutorial out, but I would start by looking through the Forums to see what other users are discussing.

You should be able to just create the code classes you need. You will of course need Visual Studio so you can compile your project.

As far as using blueprints, here is a bit more info.

[Twitch] NEW! Training Stream - Spline and Spline Mesh Components]1

[TUTORIAL] Create a procedural spline road tool in blueprints 4 part video series]1

Hi bzxo,

I’ve talked with you on the IRC previously about this topic and I just I figured out what you were doing wrong with the spline component.

You can actually make loops with current spline component if you keep aware where the spline is going while placing the spline points. This requires constant rotating, moving and adjusting tangents manually as you go. I also had to toggle between different views and use coordinate system gizmo all the time (which lets you alternate between world space and local space).

For example for that loop, you need to rotate the pitch up as you go up the loop, keeping the spline all the time going into “forward” direction. If you just drag the spline points around and try to rotate them afterwards it’s almost impossible to figure which direction you need to rotate it.

So build the spline one step at a time on loops and keep the end point always aligned correctly before adding more points. Even things like too long tangent control points that fight with next spline points tangent points can make it go bad. If things go wrong, try to figure out what’s forcing it to twist.

As additional tip, use only minimal amount of spline points for the shape and try to get the roundness with rotations and tangent controls. This will not only mean you have to do less work, but you also get smoother transitions and have less issues overall.

Only thing I couldn’t do with spline component was a single loop using spline component’s looping option (which you have on your example pictures). If I do put the loop option on and actually let it connect later on when spline goes around regular way it connects just fine.

Do note that there still is an issue with spline mesh twisting at certain rotations but that happens for another reason. What I described here will help you get the spline component itself to flow correctly.

Here are looping and twisting examples with spline component’s loop connection option enabled:

Great news, thanks for clarifying this!