Physics.CheckSphere get collision GameObject

How can i get the Gameobject the Sphere (Physics.CheckSphere(GroundCheck.position, groundDistance, groundMask)) is colliding with? I have tried with the OnCollisionEnter(Collision collision) function but i didnt work out. Is there a was to get the collision GameObject?,Hello,I am currently checking a collision with a wall like this: isWallJump = Physics.CheckCapsule(WallCheckBottom.position, WallCheckTop.position, 1f, groundMask); but i need the GameObject that im colliding with.

You could use Physics.OverlapSphere as it returns an array of colliders. Then you could use a for loop to get the specific collider and collider’s details you need. Here is a code example:

 Vector3 pos = new Vector3(1, 4, 0);
 float radius = 1f;
 Collider[] cols = Physics.OverlapSphere(pos, radius);
 for (int i = 0; i < cols.Length; i++)
      print("position of collider " + i + " is " + cols*.transform.position);*