Unity - Trail Renderer (with colliders!)

March 14, 2013 in Unity

Hey guys, just a quick post to show what I’m working on just now. I really ought to be doing some coursework but that’s just no fun sometimes.

So I was poking about in Unity and noticed that they have something called the Trail Renderer which acts like a particle effect that is produced as an object moves and leaves behind a trail. Simple stuff eh?

So after reading about this and trying it out with just basic colours my first thought was Tron! This inspired me to try and recreate the famous light bike scene from both the original and the recent sequel. Sadly though the light trails have no native colliders which made things a tiny bit more difficult. Instead of just leaving it at that I started adding in box colliders so that collisions with the light trail can be made easier.

Figure 1. Light Trail with Colliders

As you can see, I’m currently finding it difficult to match up the length of the trail to the length of the trail of box colliders! Currsently I have a few ideas how to match it up which I have yet to implement but another easier solution would be to just get rid of the light trail entirely and replace the code I have with textured boxes. I’ve yet to decide which technique will be better for this.

Figure2 . Close up of the trails Colliders still need resizing.

Anyways it’s still a work in progress so I’ll post updates when I can. You can find the latest version of this prototype on my Unity blog.

Thanks for reading! Let me know what you think of this article on twitter @7thsanctum or leave a comment below!