Download

Generating Spline Points In Runtime

Hey guys. I’ve been digging and I’ve found tons of stuff on making splines in the editor, but I’m trying to understand the best way to create a player-made spline. For example, in my game there’s a lot of crafting, and I want the player to be able to lay down a fence that will follow the curvature of the ground. I can’t seem to find anything on how to go about this process, though. I’d really appreciate any suggestions. It doesn’t necessarily have to be perfectly step by step, just something that can give me an understanding of how it might work.

I can figure out how to place the initial spline mesh, but not how to add the points correctly. What I have is a line trace where the initial spline mesh is placed, and then I do another line trace to decide where the end will be. Calculating the points between is my issue. This was what I tried, but to no avail:

I’ve also tried this:

Have you tried doing it all in world space? Get rid of the add and change this to world:

I shall give that a try and report back!

Edit: Unfortunately it doesn’t appear to be changing the spline object.

I just did it like this

For some reason, there’s a huge framerate hit while it figures out where the new point is, but it works:

splinepoints

Instead of the debug sphere, would I spawn the spline mesh actor?

Ah, wait, spline mesh. Hold on…

I think I might be missing something somewhere.

I can spawn the initial spline just fine, but I can’t seem to change/add spline points to it.

Basically, the player sets the ‘start’ point, which is where I am spawning the initial spline object, but then I need them to set the end point and have the mesh update accordingly.

like this:

But you have no control over tangent:

splinemesh

Ah! That works wonderfully! I’m sure I can tweak it more, now that I understand how to do it. Thank you so much for taking time out of your day to help me with this!

1 Like