Thursday 14 March 2013

Unity - Trail Renderer (with colliders)

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?

More info can be found in the Unity Documentation.

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! Currently 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.

Also check out the following video which inspired me to make this :




Email : markmmiller@hotmail.co.uk
Xbox Live : Dr Death MK 2
Steam : 7thsanctum

3 comments:

  1. Hi! Any luck with the trail + colliders? I was experimenting as a very beginner with something similar by creating cubes with colliders after an x amount of movement, but i can see the distance between the cubes vary a little and the number of cubes is huge just after few seconds of play.

    ReplyDelete
    Replies
    1. Hey, I haven't looked at this project for a while. This method was the best that I came up with at the time, there might be newer features in Unity that could do this better although I'm not sure.

      For the number of cubes it really just depends on the spend and length of your trail. I tried to time it so that the cubes were destroyed when the trail ran out and the trail would shorten faster depending on your speed so not too many were created.

      Delete
  2. Im doing a drawing app with trail renderer, and planning to do a eraser function with code i found below.

    Trail with Collider, but 2D.
    http://wiki.unity3d.com/index.php/TrailRendererWith2DCollider

    ReplyDelete