How can i see if a gameObject is touching another that is touching the ground?

Hard question to explain but i’m quite new to unity and need some help.

Basically how can i check if there is a path of gameobjects to the floor from where a gameobject is.

This image shows a stack of 3 cubes (no rigidbodies) with colliders
The top one is checking if it is indirectly touching the ground and it is

This shows the middle cube has been removed. Now the top cube isnt indirectly touching the ground.

Is there any way to check for this connection? This is in a 3d game btw not 2d.
In practice this would be done with more complex objects than cubes.

Thanks for your help!

For this you have to smartly place your objects and check scene view whether their colliders are touching or not.

Following changes can help you view colliders better : Set first drop down to wireframe and second to overdraw as shown below and select all cubes.


After you have checked then revert these changes as scene looks empty.

Start off with your “top” cube. Found out what objects it touches. Then for each of those objects, find what they touch. Do this over and over until you run out of options, or one of the object touches the ground. You’ll need to keep a list of what objects you’ve already tested, since, if A touches B, then when you look at B it’ll touch A, and you don’t want to check A again.