Creating a distance displayer

In this recipe, you will learn how to create a distance displayer, which can be a very useful feature. For instance, when we want to display the proximity of an object or a character, a visual displayer or even an auditory distance displayer can give us a better indication of how far or close we are from a particular thing. This is done in order to assist us during gameplay, for example, to avoid a particular enemy, or not enter a dangerous region of a game.

How to do it...

  1. To begin, we have to create a UI image that will be our distance displayer. Right-click on the Hierarchy panel, then go to UI | Image, and rename it DistanceDisplayer. Of course, it is possible to resize the image, change Source Image, and then place ...

Get Unity UI Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.