Hello,
I’m trying to make a spline at runtime, and I want that spline to be visible to the player, using a Spline Mesh component. I have looked into a lot of posts on this forum and into tutorials, but for some reason I am not able to make it work.
What I would like is for the mesh to follow the shape of the spline. At the moment I’m testing with just two spline points, ultimately I’d like to have more and to make the spline curved.
Note that I’m doing all this in the Event Graph of my actor, because I want to be able to change the spline at runtime. The following logic is triggered by Begin Play:
Note that the spline has the right shape (the white line) but the mesh doesn’t. It follows the spline’s default shape, seemingly ignoring the points that are added in the first screenshot.
I don’t know what the red squares are.
What am I missing? I’ve been trying things for hours and nothing changes.
I have the same result if I put all that logic in the construction graph
I’ve tried looping the logic infinitely, doesn’t change anything
Setting the Spline Mesh’s axis, or mesh outside of the node that creates it, or attaching it to the spline, also doesn’t change anything
I’ve tried adding more spline points and it did create a longer mesh (or, I guess, more meshes) but nothing that followed the entirety of the spline.
Thank you in advance for any help you could provide.
This spline has 6 spline points and needs 5 spline mesh components, 1 for each segment.
In your example, you are subdividing the spline into more sections than there are segments, using spline length and the dimensions of the spline mesh - is this intentional?
have you accidentally overengineered it?
or are you deliberately going beyond what is considered the usual approach for a reason that is yet to mentioned?
red squares
Handles for manipulating the Bézier curve - adjusting tangents.
Which doesn’t look as neat as yours but that’s progress! Thanks a lot, I basically copied your logic.
One issue that I discovered is that I had set the spline mesh’s scale to 0.1 accross the board, which might explain why it didn’t go all the way? I think I expected it to be extended from one point to another, but maybe that’s where I was wrong.
It seems the meshes leave the last segment empty, but that’s something I can probably fix.
This will ensure you can make something like a snake’s tail that tapers off, or a river that is wider here and there, not necessarily the same scale across the entire component. And, most importantly, will not confuse the spline which cannot handle a scaled component well (or at all).
This is the spline shape that I want, but the mesh is not following the curve.
This is the code that generates the spline. It’s only three points and a bit hacky at the moment, but that’s how I managed to get this nice curve at runtime:
I’ve checked and the tangent the mesh component is getting is the correct one. I also noticed that the meshes are stretched a bit weirdly, but that’s something I can live with at the moment.
I only have three meshes in there but I feel they should be deformed to follow the spline, right? I tried adding more points to have more meshes but I tested that in the construction script because I didn’t know how to reproduce that curve with more points. But in those cases the mesh did not update at all anyway.
Ah, and I’m using a mesh I made in blender, it’s just a simple cylinder, here are the specs. I have no idea if that’s enough triangles or not.
Not really. It goes back to what we discussed originally. You need to make a choice. You either use a straightaway approach of 1 spline mesh per 1 spline segment (3 vs ¬20 here, atm) or you need a much more complex setup that subdivides the spline. Not sure if this can be done in BPs; last time I checked, not enough data was exposed.
When it comes to mesh stretching / deforming weirdly:
does the cylinder have enough rings to deform and follow curvature?
In the first screenshot? Now I’m even more confused. Maybe the discrepancy comes from the spline creating three points and the “make mesh” function using spline segments and somehow finding more?
Here’s what I’m trying to do: This is for turn based combat, where the player has a vehicle. In between turn I want to show a spline representing what their vehicle’s trajectory will be next turn. The player would change speed, turn, etc… and that would update the spline accordingly (for example, if they increase speed, the spline becomes longer). And when they click “End Turn”, the vehicle follows the spline.
I just checked the mesh and it seems it does NOT have nearly enough rings:
Sorry, our replies crossed. I added a screenshot of the mesh to my previous message, and it indeed looks like it doesn’t have enough rings. I’ll look into that.