How would you approach adding solid TRON-style light trails to a 3D game?

Hello everyone! I followed the official Unity Roll a Ball tutorial, and I’m working on modifying it to make it more my own! I added some AI to the game, and I was considering doing something like TRON light cycles or like GTA Online: Deadline to make the game more exciting. For example, I’d like to do something like this:

.

In essence, I’d like to leave a trail behind the player (or AI) that has a collider on it. The trail will slowly fade away as time goes on.

I’ve been doing a lot of research/reading and I’m not entirely sure how to tackle adding the solid light trails/ribbons. I’ve found a lot of old forum posts that suggest using a TrailRenderer, but it seems that in a 3D space, this would not be ideal because of the “billboarding” effect. Next, I tried to modifying this tutorial into a 3D space, but I couldn’t seem to get it going, also, it seems that since I’m not limiting the player to just 90 degree turns that this method may not work anyway.

My question is, how would you approach adding the solid TRON-style light trails to a 3D game? Any tips or suggestions would be appreciated!

I would produce renderable wall segments as well as colliders in real time.

The spawned objects would have a mesh, a collider, and some timer (or distance checker) on them, to automate their fade out animation and self-destruction.

The mesh itself would be rendered with a dedicated shader to produce the desired visual effect, and the collider would be used to detect physical contact with the bikes.

It’s not exactly trivial, but it’s not that hard either, mostly because each instance of the script would monitor just one bike, track its position and update itself in real time, acting simply as a dynamic spawner of wall segments. You probably want to spawn a wall segment when the bike hits a maximum distance, or when the angle between two wall segments (due to steering) becomes too acute.

Because this occurs only occasionally (the wall is built one segment at a time while the bike moves), such rhythmic spawning would become apparent, so you also want a temporary wall segment that will stretch in real time, until it “solidifies” into a permanent wall, only to start a new temporary wall segment. This way you get the smooth experience, and the wall looks like it’s persistently and continuously drawn by the bike.

The shader could be made to ignore backface culling, with each wall segment made out of just 2 triangles (visible from both sides). Their density would compensate for the curved wall so that it doesn’t appear too jaggy. This can also support the walls with a Y bump, when jumping.

For starters, learn how to create procedural meshes in Unity. It’s a deep topic, but it’s pretty much required, in my opinion, to get this done. Your needs are not so complicated, so it is enough if you learn the very basics of mesh generation, you don’t even need texturing, and there are ways to implement simple gradients (if you so desired) by introducing vertex colors and playing a bit with the shader.

1 Like

Thank you for the input here, and a huge thank you for going in depth- I’m going to try to apply your method as it seems to make the most sense to me out of everything I’ve read online! Procedural meshes seem to have a lot of uses, so I think it’s worth my while to learn anyway!

Here is a free asset with source code which might help getting you started on the mesh generation:

2 Likes

This is awesome! Thanks for sharing, I’ll be checking this out!