how i can make a collision of a trail?

i been trying to make a collition for a trail of a vehicle like in tron: legacy but i dont know how to do it, i tried to add collition to the ribborn that you may see in the image attached


i don’t know what i should add or do, can someone guide me please?

You will need to spawn a sequence of Box collisions that conform to the trail.

Ideally, manage these box collisions inside a single Actor/Component for the sake of performance. But the logic flow should look roughly like this.

Record Location of Vehicle as [PriorVehicleLoc] …then… When Vehicle has moved a Distance>[RibbonResolutionDist] Create a Box collision with a length equal to the distance between [PriorVehcileLoc] and [ActorLocation]. Assign each Box collision to a Map/Struct with a [Lifetime] equal to the lifetime of your Trail.

Keep track of these Collisions in your map, and tick their lifetimes down by Delta time every tick.
When a box’s lifetime is <=0, destroy it!

It can seem a bit faffy, but this is generally how things like this are handled in games.

[RibbonResolutionDist] will need a strike a good balance between accuracy and optimization. too.

thx for the response!, i’ll try and show you the results, i was trying recently with instanced static mesh like this:


but now that i got your response, i’ll try that, thx!

My runtime gizmo plugin (Position system finished, I am working on Rotation system) has a custom collision box feature (it is finished, too). You can define any shapes with TArray and you can change its shape at runtime.

Each FVector represents a vertex position.
You can do like this.

  • Create a spline
  • Get position from at every for example 10cm (depends on your smoothness requirements)
  • Offset and store them for three times (for thickness and height). (1st set original; 2nd set 10 cm left; 3rd set 200 cm above; 4th set 10 cm left and 200 cm above)

You’re along the right lines! Switch those to box collisions and set the right length based on how often you’re spawning them and you’re on your way!

curved lines won’t be good.

They would be absolutely fine. It’s a high speed vehicular game. If there is at least one box collision per 2 metres the resolution of the collisions wont be noticeable.
At the very least, if it becomes a concern, you can increase/decrease the resolution based turning angle.
But I don’t that will be necessary as in Tron vehicles typically crash almost perpendicular to the line.

Consider the Spline + Spline Mesh Component combo. The mesh can be deformed to make it follow spline curvature closely, collided against, the spline can be further subdivided if needed, it’s pretty performant if you do not update the whole thing every frame; instead, update only the last 2-3 segments to keep tangents consistent - something you also have easy access to.

1 Like

i got a solution for my problem, i used splines and mesh splines like @Everynone said so i did this code in the constructor to add a count of splines


and this code for following the movement of the motorcycle in the event graph in the vent tick:


and then i added a spline mesh component its created based on the count of points of the spline in the constructor script


and to make the spline mesh i did this code in the event graph in the event tick:

and the final result its something like this:


now, its easy to resolve my problem just adding the collition to the mesh and etc, ill see if i leave the mesh visible or something else.

NOTE: if youre going to use the graphs the variables/numbers you can change if you ever need to its the alpha on the lerp to make it to follow faster your target, if you want more “breaks” in the spline just add it to the count variable.

if you want the trail/spline follow an object i highly recomend creating an scene object to get the ref to what to follow

thx to the ones that helped me into finding the solution @AliceHalley @Everynone !

update: I was wrong about a lot of things, like in the spline mesh because it was causing a lot of lag by adding the collition and executing it at the event tick, and adding the lerp, it was causing to not follow the ribborn trail, instead i did this:


[ignore the instanced mesh, i did that because i was thinking that it will resolve the issue, but no] i deleted the lerp and anything related to it, then i added this nodes

and disconect all of event tick and set it to timers, so it updates every time i want, and thats it, this is my final result:

LightCycleDemo

ignore the spline mesh, it can be set hidden in game

As above, you only need to update the 1-3 last segments. Not all of them… There would no need to run any loops whatsoever - which are the slowest thing in BPs.


Admittedly, there’s a lot of ways to accomplish something like this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.