How to create a transparent circle around a GameObject indicating it's range.

Hi guys.

I’m attempting to create a transparent dark circle around a gameobject, when said gameobject is clicked, which will indicate that objects radius.

The logic of making something display on click i’m 100% OK with. No need for an explanation there.

It’s the drawing of the circle which is bothering me.

I have tried a few methods involving circle sprites and using a C# script, however neither yield a transparent result.

I’m very new to Unity so if you guys offer some nice suggestions involving shaders or meshes (more advanced methods) if you could provide a little detail on how to use the answer that would be awesome.

Thanks,
vddox

You can use just a sprite if the ground surrounding the gameobject is flat anyway. Just make it with some transparency in the image or even just change the color alpha to be a little transparent. Scale it to match the “range”.

Okay i’ve given this a try and it worked, thanks! Although I have now come across another issue.

How do I know what size the circle is in world units? There is scale on the transform component but this scales the sprite by it’s size rather than the world units. I’ve always found it hard to find a relationship between sprite size and world size.

I usually just try and setup my assets (the sprite texture) to be a very specific size, and then bring that out onto a sprite, and eye ball it, and try and decide if its X units in width by default or whatever… then from there you just multiply by however large you need it to be in comparison to its default scale. Like for instance if it ends up being 5x5 units in size by default, and you want it to end up 15x15 to represent the range, you would just multiply the scale by 3, or alternatively if you wanted it to be only 2.5 by 2.5, you’d multiply by 0.5 to get it the right size.

You can make the default scale whatever you want really, it just depends what you save the prefab at.

if I am not wrong, you can select the sprite (not the gameobject), there should be an option “pixels per unit”. Default is 100 pixel. Then as example, 200px200px is 22 units world size.

1 Like