10K: Using Unity's Line Renderer


This is the third (or fourth, if you count each part of the Curious Fixation pieces as a single entry) in a series of postmortems where I will be discussing my previous projects. 

10K is the only project I've worked on with another programmer and no members of another discipline! It was also my fifth game jam game for 2018. Tyler and I have previously worked together on The Monkey Way and Search and Rescue as a part of a larger team. He's part of studio Jagerware working hard on a great looking game called Kitsune, check it out!

10K was made for Secret Jam 2018 under the themes Retro and Three Button Input. All code had to be completed within the jam (excluding) game engines. The two themes primed visions of old-school arcade visuals e.g. Space Invaders, Pac-Man et al. We assembled a prototype using ...

P R O    B U I L D E R 

The tunnels were simple pipes, constructed using Pro Builders New Shape Tool for pipes of various side counts, then detaching each face to get a straightforward reference (Gameobject/Transform), usable in code. Why do that?

L I N E    R E N D E R E R 

If you were to google search wireframe unity you would likely receive a significant amount of references to shaders, and an Editor-only capacity to render scene objects as wireframes using OpenGL settings. I've never written a shader in this life, and by my estimation a weekend game jam with only other person was not the place to start. I definitely wanted to learn something new and for the game to hit some kind of retro visual style, but I also wanted to finish a game.

Enter Line Renderer

Line Renderer draws lines in view space by default. It supports adding > 2 points in order to form longer lines... but doing so produces visual artifacts, an issue that will most likely not be addressed by Unity given the problem goes back nearly a decade. This isn't a dealbreaker for small applications though, since a a one parent - many children structure (see: Curious Fixation) works just fine. In 10K, I had a script attached to a parent object which selected a random colour from an array set in the Editor. 

Wireframe Colour Parent: Custom script as it appears in the Inspector.

Wireframe Builder: Custom script as it appears in the Inspector.


To facilitate the drawing of a border around a plane, each gameObject associated with a plane instantiates three (and not four, as the planes form a loop to close the volume) children with their own line renderer components. The line colour is retrieved from the wireframe colour parent to ensure uniformity. Once the lines are rendered, you can disable the mesh renderer and presto, wireframe model.

Code: here.

If you're interested in the more performant way of drawing wireframes (using shaders), check out Catlikecoding for an excellent series of tutorials.

Get 10K: Line Art Arcade

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.