Draw the circumference of a Physics.Overlapsphere

Hello,

currently I’m using Gizmos.DrawWireSphere to show the circumference of my Physics.Overlapsphere. The problem is I don’t want to just show the radius for debugging and I want the player to be able to see it. So, how would I go about drawing this circumference in game?

After doing some research I found a line renderer would do the job I needed.

Here’s the solution for any passers by:

    float theta_scale = 0.01f;        //Set lower to add more points
    int size; //Total number of points in circle
    float radius = 2f;
    LineRenderer lineRenderer;

    void Awake()
    {
        float sizeValue = (2.0f * Mathf.PI) / theta_scale;
        size = (int)sizeValue;
        size++;
        lineRenderer = gameObject.AddComponent<LineRenderer>();
        lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
        lineRenderer.SetWidth(0.02f, 0.02f); //thickness of line
        lineRenderer.SetVertexCount(size);
    }

    void Update()
    {
        Vector3 pos;
        float theta = 0f;
        for (int i = 0; i < size; i++)
        {
            theta += (2.0f * Mathf.PI * theta_scale);
            float x = radius * Mathf.Cos(theta);
            float y = radius * Mathf.Sin(theta);
            x += gameObject.transform.position.x;
            y += gameObject.transform.position.y;
            pos = new Vector3(x, y, 0);
            lineRenderer.SetPosition(i, pos);
        }
    }

I don’t know if you’ll ever see this but I’ve ran into the same problem you did. Problem is: I have absolutely no ideia of how Line Renderer works. After doing some research, I kind of figured out the general ideia. However, I can’t get the Con and SIn parts. Simply trying to implement the code you gave only draws the line when viewing 2D mode, nothing is shown on 3D mode. I suspect that’s because Z always 0. Can you tell me how you did it, please? Tyvm in advance!

@Arcana96