How to Generate splines in real time? Like GTA 5 gasoline trail

Hello everyone and thank you for taking the time to read my query.

This is a topic I have seen requested several times over the years and still no real answers or tutorials on it, that I can find. I believe this type of effect is used in GTA 5 also when you create the gasoline trail.

The main reason I am looking into answers for this, is there is more than one way to go about achieving the result I’m after, I’m also looking at a better way to limit computational power with it.

Ok, so here’s the full deal:

  • I want my player to have an ability that is cast upon holding a button down. It’s disabled and on cooldown upon release or meter depleting.
  • The ability leaves a trail behind the character with a set lifetime.
  • The trail has collision.
  • The trail is a gas effect not a mesh. Currently using an emitter.

So like most other articles I’ve read, people are having the same issues of splines not generating in real time, at best they duplicate the actor over and over instead of adding additional points to the first spline spawned.

So, there may be other ways to do this, however I am using splines in this case as I haven’t sourced another way to achieve the 2nd part of my players’ ability, which I believe will require splines.
The 2nd part of this ability is, when the trail is made, if at any point during its lifespan it intersects with the spline it will create a closed loop and calculate the area inside. This area will light up with a decal/effect which also acts as a damage over time effect to any enemies standing in this area.
Due to this 2nd part of the ability, the spline trail might cause intersections if the player is using the ability standing still, so would therefore only add additional splines points if the player is moving.

I am very new to UE4, however I have been able to pick up blueprint scripting fairly easily, not to mention the enormity of tutorials out there, but there is always something new to learn!

I appreciate any blueprint builds/ideas/tutorials provided and again, thank you for your time!

So like most other articles I’ve read,
people are having the same issues of
splines not generating in real time,
at best they duplicate the actor over
and over instead of adding additional
points to the first spline spawned.

Real-time splines have always been a thing, it’s actually fairly straightforward:

Once you have a spline, add spline mesh components, by default they have no collision but it can be added:

You will need collision for interaction, it does no need to visualised but can be to display a gasoline trail. You will need particles once lit.

You will need collision for
interaction

edit: or perhaps not since the plan is to turn it into a shape

Ah, creating shapes like this is more complicated and you may need to reinvent the wheel to get it going in blueprint! But approximation may work OK if it does not need to be super precise.

Never made anything exactly like this so what you’ll find will probably be better but the first thing I’d try:

  • average spline points to get a centre
  • start drawing / appending procedural triangles to form a procedural mesh
  • enough tris to reach each spline point

Sounds feasible but, most likely, on order of magnitude more complex than 3 bullet points.

Good luck, do tell how it goes.

Thanks for the prompt response Everynone, looking at the blueprint it is very similar to what I have, only the indexing is slightly different, which is where I have probably gone wrong. I will try this out later tonight.
The mesh/collision side of things is fairly straight forward as you’ve pointed out.
I did find an article similar to what I want to achieve as part of the second part of this ability when the spline overlaps and creates a closed loop it forms the shape inside, like the image attached. I’ll work on this and if I get it running, I’ll post my results. Thanks again!

Well, I did manage to get a fair bit of it functioning, after what was a bit more than 3 bullet points :stuck_out_tongue: I found a tutorial which assisted in building the blueprint, basically builds a grid based off the bounds of the spline points then get triangles based off that grid and so on.
The link for the tutorial is here:

I have put this on hold for the time being, however I have another thought towards achieving this, hack apart an existing blueprint containing procedural mesh generation and use that. A few alterations in there but the basics should be there.

I looked at this and while not perfect, this is rather brilliant. The math is straightforward but the top-down view on things is pretty awesome.

Thanks for sharing this!