x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

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, 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:

alt text

alt text

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:

alt text

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.

alt text alt text

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.

Product Version: UE 4.12
Tags:
more ▼

asked Jun 02 '16 at 10:21 PM in Blueprint Scripting

avatar image

Monokkel
152 7 10 21

avatar image Lynkk Jun 23 '16 at 02:59 PM

Did you find a solution?

avatar image Jonas_Molgaard Sep 17 '16 at 11:39 AM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

Getting the up vector and rotation

Get Average Distance macro.

The 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.

Get the roll and scale

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)

Get Relative Roll function

And finally creating the spline mesh component.

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.

more ▼

answered Oct 06 '16 at 01:39 PM

avatar image

lispink
36 1 4

avatar image Jonas_Molgaard Oct 06 '16 at 01:44 PM

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

avatar image Jonas_Molgaard Oct 06 '16 at 03:53 PM

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

roll logic.png (795.9 kB)
avatar image Jonas_Molgaard Oct 06 '16 at 03:55 PM

without roll logic alt text

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.

avatar image lispink Oct 06 '16 at 04:25 PM

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.

avatar image sandermann Nov 22 '16 at 07:43 PM

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?

avatar image lispink Nov 25 '16 at 03:57 PM

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 constuctionscript overview Store number of track points Store actual spacing Get total spline distance Draw track numbers

Again hope it helps

avatar image lispink Nov 25 '16 at 04:12 PM

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 Overview Variables Calculating and creating spline mesh components Track Numbers Get relative roll at distance allong spline + macros

Again hope it helps

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

avatar image sandermann Nov 26 '16 at 12:00 AM

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?alt text

image.jpg (756.5 kB)
avatar image lispink Nov 28 '16 at 06:05 PM

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.

relative up vector Relative roll and pitch

avatar image sandermann Nov 28 '16 at 05:18 PM

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

avatar image lispink Nov 28 '16 at 05:52 PM

The first image has the defaults on the right side.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

@lispink, are u actually working on something ?

more ▼

answered Dec 04 '18 at 10:40 PM

avatar image

N.0.E
1 1

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question