- Home /
Is there a way to render in-game a sphere collider?
I'm trying to show the collider of a game object as in any tower defense game where you can see the range of each tower. Anybody knows if this is possible? Or some other solution I can use?
Collider is a confusing word for this. It sounds like you just want to draw a big circle-edge. Does "unity draw edge of circle" really have no hits?
I've never seen a Sphere used for "how far this gun can shoot." Do you really want 3D? A big hollow ball around the gun?
$$anonymous$$aybe I'm approaching this the wrong way. I'll take a look at the shaders though. Thanks.
Answer by _Gkxd · Jul 10, 2015 at 02:50 PM
Edit:
Unfortunately, the method I posted using Handles
won't actually work in a build. The easiest alternative solution that I can think of is to render an image of a circle where you want. If you want a very high quality circle, you can manually create a polygon mesh and render that.
You can use Handles in an actual game by including UnityEditor at the top of a script.
Correct me if I'm wrong, but I'm pretty sure that you can't successfully build a game if one of the included scripts (those outside the Editor folder) use UnityEditor.
I was not aware of that. I was using it in a few things to draw bezier curves, but I never tried building with it. Thanks for letting me know.
Answer by Cherno · Jul 10, 2015 at 02:52 PM
A collider ultimately uses a normal mesh, so if you want to view this mesh, you could, for example, use it as the mesh of a MeshFilter and add a MeshRenderer on top of that. Depending on your needs, you could use a special shader that is transparent or whatever to show a tower's range.