public LayerMask groundObjects;
    public Transform groundCheck;
    float checkRadius = 0.2f;
    bool isGrounded = false;

    void FixedUpdate() {
        isGrounded = Physics2D.OverlapCircle(groundCheck.position, checkRadius, groundObjects);

    void OnDrawGizmos() {
        Gizmos.color = Color.yellow;
        Gizmos.DrawSphere(groundCheck.position, checkRadius);

Physics2D.OverlapCircle() is used to check if some objects are within the specified range. It returns bools value so that we can assign this value to the variable.

First argument  sets the circle position, then it’s radius is specified. Finally we can check what objects are to be affected. We can make it by setting thoses layer mask and assign this mask in the inspector as a third argument.

OnDrawGismos() method draw the gizmo for visualization purpose. The gizmo will be shown only in scene mode (not in game mode).

Leave a Comment

Scroll to Top