Gizmos.drawline not working

Somehow my gizmos never drawn on the Scene view, i have tried to turn on/off the gizmos display button, reinstall Unity and still not found any solution. I want to draw a line under my Player feet so i wrote a Player script and implement this method and attach the script to the player.
Here is my code:
void onDrawGizmos()
{
SpriteRenderer spriteRenderer = GetComponent();
Gizmos.color = Color.red;

  Vector3 origin = new Vector3(transform.position.x, 
  transform.position.y - spriteRenderer.bounds.extents.y);
  Gizmos.DrawLine(origin, origin + Vector3.down * 0.1f); 

  //Draw left foot
  origin = new Vector3(transform.position.x - footOffset, 
  transform.position.y - spriteRenderer.bounds.extents.y);
  Gizmos.DrawLine(origin, origin + Vector3.down * 0.1f);

  //Draw right foot
  origin = new Vector3(transform.position.x + footOffset,
  transform.position.y - spriteRenderer.bounds.extents.y);
  Gizmos.DrawLine(origin, origin + Vector3.down * 0.1f);

}
I used both Unity 2022 and Unity 6

You could use debug.drawline etc.

I dont remember the exact reason why that was the case for me, but hopefully that’ll help your needs

1 Like

It’s “OnDrawGizmos()” (note the upper-case): Unity - Scripting API: MonoBehaviour.OnDrawGizmos()

Note: You should try to avoid using “GetComponent()” method in Unity if you can, instead try to use:

 GetComponent<SpriteRenderer>() 
1 Like

thanks you, i have found the solution

this is my solution thanks you

1 Like