Thumbnail Drawing range indicators in Unity3D scenes

Door: Thijs Zumbrink
31-08-2016 18:42

For my game I stumbled on the need to draw range indicators. When a player builds a structure, there must be visual feedback regarding (attack) range of the new structure, but also the ranges of all nearby friendly or enemy structures. As with any problem, there are many solutions, so here is an overview.


This is the quick 'n' dirty solution, which requires little effort, but only looks good enough for quick prototyping.

Geplaatste afbeelding

The structures (little squares in this case) carry a wide, flat cylinder with it. It has a transparent material, colored according to the team, so the ground underneath is visible.

The downside of this approach is that it's not pretty without a proper material, and it requires a flat ground.

Line renderer

An alternative approach is to use a line render, which draws a line in 3D space. It requires some more setup than a cylinder, because you'll probably write a script that generates the vertices.

Geplaatste afbeelding
(In this case the indicator of the structure to be placed is red, for easier distinction.)

It looks a bit nicer, especially with Unity 5.5 incoming, bringing improvements to line renderers. However, we are still hindered with requiring a flat environment. We can get around it somehow by projecting the vertices onto the terrain, but it won't be perfect.


Probably the best solution is to project an image onto the terrain, using Unity's Projector component.

Geplaatste afbeelding

This gives automatic projection onto the geometry so there is no clipping going on and the ground doesn't need to be flat anymore. It also gives artistic freedom of the shape and decoration of the range indicator, since the projector simply uses a texture. There are also drawbacks: the standard projection shader doesn't give an option to boost the brightness, so the result can look dull. Also, the projection will intersect anything unless you use layers to exclude certain objects, like trees and buildings. Finally the result will look slightly "pixelated", since a texture is less precise than using geometry for the job.

Log in of registreer om reacties te plaatsen.