Moving the circle

This is great, but you'll likely also want to change where the circle is at run-time, which we can do via code. If you want the circle to follow your character, other steps are necessary:

  1. Create a new C# script called SetRadiusProperties.
  2. Since you may wish to see this change both in the game and outside, we can add a tag to the top of the class saying to execute this code while in the editor, in addition to when the game is being played, by adding the following tag:
[ExecuteInEditMode]public class SetRadiusProperties : MonoBehaviour
  1. Add these properties to the script:
public Material radiusMaterial; 
public float radius = 1; 
public Color color = Color.white; 
  1. In the Update() method, add these lines of code:
if(radiusMaterial ...

Get Unity 2018 Shaders and Effects 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.