Runtime Spline Mesh Component only generating once?

Hey all! Having an odd issue that I have been banging my head over for the last 24 hours. I have been trying to make spline meshes in real time, and I am almost there, but I keep having an issue where only one new mesh is drawn, no matter how many points I add.

In my world I have 2 spline points already made:
Screenshot 2021-11-16 111111

When I call “Draw All Spline Meshes”, the mesh shows up as expected:
Screenshot 2021-11-16 111223

Then when I call “Add New Spline Point”, then call “Draw All Spline Meshes” again, it shows as expected:

But then every spline point I add after that is ignored by “Draw All Spline Meshes”, and no meshes are generated…
Screenshot 2021-11-16 111337

Any ideas here? I’m sure I’m doing something dumb lol.

Here are the functions:


At first glance: If you start at index 0 and subtract 1, it will try and search for point at index -1.

1 Like

I saw that too, this code originated from a tutorial, but the tutorial was using it in Construction Script. I changed it like so and now it will draw the mesh, but the mesh is messed up.


Try giving this a try: UE4: Understanding Splines. A tutorial | by Christian Sparks | Medium

Yours is different here:
image

1 Like

If i make the function the same way as that, I get the same behavior. It will only add 1 mesh.

Also, if I eject from editor and move a point manually, then re-posses and call “Draw All Spline Meshes”, the mesh is drawn correctly… I’m so confused.

Notices here, he subtracts 2 from the total points of the spline: that is to not go out of bounds of the array.
image

If you have 4 points and you’re accessing 2 at a time → you need to loop 1 less time to not go out of bounds. So from 4 points in the spline (0 → 3), you want to loop 3 times, not 4, like this:

  • Index 0: 0 → 1
  • Index 1: 1 → 2
  • Index 2: 2 → 3.
2 Likes

Yeah I’m not confused about that. I get that. This is how the function looks currently.

It draws the initial meshes, and one addition mesh added during runtime, but not 2+. All subsequent meshes are not generated unless I move them manually in editor, then call “Draw All Spline Meshes” again. So it is the same issue as my first post.

I’ll try it later to see if I get same result.

1 Like

Odd… If I move all of the points 10 units on the X axis, then the meshes are drawn correctly… But obviously they are no longer in the correct location…
Added this:

And now I get this. Now to figure out why moving all points and redrawing meshes fixes it… :man_shrugging: Seems like it forgets the other points locations somehow and running Set Location At Spawn Point refreshes it? But even if I do that and don’t actually move anything it doesn’t work. The points have to be moved for it to work.
Screenshot 2021-11-16 144649
Screenshot 2021-11-16 144705
Screenshot 2021-11-16 144719
Screenshot 2021-11-16 144736
Screenshot 2021-11-16 144807

Edit: Thinking this may actually be an engine bug… Anyone have any other advice here? The only way I can generate the meshes is if I move the points by some arbitrary amount before generating the meshes. If I don’t move them, they do not spawn…

Edit 2: @Everynone I see you have helped a few fellows before with spline meshes. Can you give me some advice?

Edit 3: Just figured out that the subsequent meshes are being drawn, but they are being drawn like this:
Screenshot 2021-11-16 200405

I took new function pictures if it helps make it easier to understand:

Edit: So it seems like there is nothing wrong with my code, I think. The issue has something to do with generating the mesh directly up. If I generate them on the X axis, it works exactly as I expect without moving any points.

Screenshot 2021-11-16 202952
Screenshot 2021-11-16 203002


Now to figure out why I can’t generate them straight up.

This seems to be an engine bug? The fix here works, however is a hacky way of doing it. There any other reason why this is happening?

Doubt it.

AddSplineMesh

1 Like

Will look into this. I actually got it working a different way, but this looks easier.

The way I did it if I spawn points before drawing the meshes everything is fine:

However if I spawn the points after drawing the initial mesh, I get this:

Screenshot 2021-11-16 223454

And I am calling Update Mesh on each mesh that was spawned:

Screenshot 2021-11-16 223725

well… you need the points first, because they give you the vectors to set on the mesh. :sweat:

Then what does update mesh do? I was under the impression that it would recalculate the way the mesh would be drawn based off of the new points?

image

Yes I have seen that. I am guessing “render state” isn’t what I was thinking it was then. I thought it was the way the mesh is actually rendered in the world. I thought running Update Mesh would update its appearance. Guess I will just redraw them then. Thanks.

Actually I will just redraw the mesh between the points that changed.

Have a look here:

edit: to save one a click:

This is an old “won’t fix” bug:


Rather than build it in Z, do Z + .00000001. No one will be able to tell.

1 Like

Thank you @Everynone ! :heart:

I see it says “Resolved” in the tracker. I’m guessing the “resolution” was to not fix it, that’s why it says “Won’t Fix?”

Pretty much. The bug is here to stay and may as well exist within the UE5 ecosystem. :expressionless:

1 Like