Using meshes in splines

Hi there,

I’m very very new to using Blueprints but I want to use them in my current project to speed up my workflow when adding features to my levels. I’ve watched a few tutorials on Blueprints but I’m still very much finding my feet.

The first thing I need help with is this: I want to create a spline that I can draw out in my scene to create pipes BUT instead of the pipe mesh following the spline I want it to pull in different static meshes depending on the current angle of the spline. Here’s an example of what I mean:

The reason I want to do this is because I have a lot of ground to cover in my project and I don’t really want to spend time tweaking the spline angles as they go around corners. Instead I’d like to drag the spline out (not worrying about the exact spline points) knowing that the correct mesh will be automatically placed depending on the angle of the spline.

I’ve followed Dokipen’s Spline tutorial [Unreal Engine 4 Road Tool in Blueprints with Spline and SplineMesh - Part 1 Spline Components - YouTube][2] and have had success in getting the spacing working correctly but working out the angle is proving difficult as my knowledge in Blueprints is quite weak at the moment.

Any help and/or direction would be much appreciated!

Instead I’d like to drag the spline
out (not worrying about the exact
spline points) knowing that the
correct mesh will be automatically
placed depending on the angle of the
spline.

Unfortunately that is probably going to be more work than “tweaking” the spline yourself. Nothing is truly “automatic”. Anything that is “automatic” just means someone spent a great deal of time thinking up how to logically explain to the computer what it needs to do, then writing out all the logic, thinking up every possible outcome and situation, making sure the computer knew what to do in each situation and then converting all of that into code/blueprints. What you’re asking would require you to calculate the angle of the spline, organize all your possible meshes into an array of some sort, tell the computer for each spline point…or 2…or 3 (you’ll need rules to tell it how many spline points to examine at a time) calculate the best path again based on some “rules” you will have to define (are you averaging the spline point locations? will you have some type of sinusoidal curve or a linear interpolation of the points?) then go through your entire array and based on criteria that you set determine which mesh is the “best fit”. You will have to also define rules and data for how the mesh itself is categorized. How does the computer know which mesh is straight vs curved vs sinusoidal vs right angle etc. What you want sounds like a really cool plugin but def not something that is going to be some quick fix in blueprints. There is no node I am aware of or collection of nodes that will do what you want them to do. You would be pioneering a new plugin :slight_smile:

you will have to make an algorithm to determine what pieces will the spline spawn in witch cases (angle or distance based). As simple as that.

Maybe if you are looking at just 2 spline points. I don’t think this is as easy as you make it seem. There are nearly limitless ways you can bend a spline. I suppose the complexity will be reduced by the number of meshes the OP has available but I can see this quickly becoming quite the ordeal to create the “algorithm”. Imagine trying to determine if a piece of mesh should be “S” shaped or “L” shaped vs straight but at an angle to one side. Going from 1 spline point to another is sufficient for only straight pieces or pieces at a slight angle, but to make a right angle or a sinusoidal curve you need to evaluate at least 3 spline points. Now your algorithm has to have some logic for “look ahead” to see whether 3 or more points are necessary to evaluate vs just 2. Not saying it can’t be done, just don’t think it is as simple as “make an algorithm”. Many things are “algorithms” but that doesn’t make them “simple”. “AI” is an algorithm, but it can be extremely complex or a simple run from point A to point B back to point A. Also the OP stated they are “very very new to blueprints”. That in itself will make this more of a challenge.

Thanks for getting back to me.

@Nebula Games Inc, thanks for clarifying that it isn’t a simple fix! Alas, I’m not a programmer so creating something like this is out of my reach (I really envy coders sometimes!) I think if I was to attempt it I’d restrict the kit to have only certain kit parts (no S shapes) just to make it easier to create. Despite there not being a solution as such at least I know what it would take to create this. You’ve saved me a lot of time in the future trying to figure the issue out not knowing that it can’t actually be done in this way. I can get around the issue manually but thought it best to ask in case there was a solution :slight_smile:

@II_ADN_II, have you any thoughts on which nodes may be in the algorithm? You could say “add maths” as an answer to any situation whereas I’m looking for direction as I’m not used to visual scripting or Blueprints.

Honestly the complexity will be significantly reduced if you don’t have “S” shapes or “Right Angles”. I was looking at your drawing and based my comment off of that. If you are only going to slightly bend left or right it wouldn’t be that hard. Use nodes like “get XXX at spline point”. I believe they have location, rotation, transform and a couple other data points you can gather from the splines. Using that info you can examine the first spline point and compare its rotation or the DOT product between it and the next spline point and using some math determine if the next point is going left or right. Based on that select a mesh that is either facing left or right. If they are within a certain angle from each other select a straight piece. So assuming you have 3 meshes, left leaning, right leaning and straight this wouldn’t be too complicated. Anything more than that and you are going to get fairly complex quick. As a side note, if you are just getting started in blueprints, this series I made will help you get a grasp of the basics and give you a good foundation to build off of. You might find some helpful things in it. I also have a couple spline tutorials but not about attaching meshes, just moving objects/characters over 1 or more splines.