Hello. I am working on a tower defense game, and I want to make a support-like tower that increases nearby tower’s attacks. The problem? I want to show the player the range of this tower’s support ability through a circle.
In other words, I want this :
void OnDrawGizmosSelected()
{
Gizmos.DrawWireSphere(position, range);
}
but in the game view. Is it possible?
There’s several ways to do this and it depends on the style you want. (Ordered by complexity)
-
You can instantiate one or more a 2D world space SpriteRenderers in your scene at the tower’s location.
-
You can instantiate a UI element onto the main screen space UI Canvas and use Camera.WorldToScreenPoint to place it over the tower.
-
Have your 3D artist create a single sided ring in their tool of choice and apply a double sided material to it within unity. Then you can instantiate it and scale it at will using unity’s transform.
-
You can dynamically create a 3D Sphere/Ring/Tube/Torus/Cylinder primitive and assign the mesh to an instantiated GameObject’s mesh renderer.
-
Experiment with Unity’s Particle System, IIRC I’ve seen a particle system based forcefield visualization somewhere that looked nice.
-
You can do some sort of post processing custom shader magic, but that’s more work than it’s worth IMO.
Hopefully that helps generate some solution ideas for you.