Can i destroy this cube? Logic??


How can i check if there is any cubes “floating”.
Easier to explain the problem if i show you some examples.


Example 1: I wanna remove cube 1. I shouldn’t be able to, because cube 2 will be floating, i could check this by looping through all cubes and see if there is anybody that isn’t colliding with a cube, and if there is its a no go. But that method doesn’t work because of example 2.

Example 2: I wanna remove cube 6. Now the colliding method doesn’t work here because even though 7,8,9 and 10 are floating they are still colliding with a cube.

Hmm, i find this hard to explain. So basically, you can click on any cube to destroy it, but you shouldn’t be able to destroy it if there is any cubes “floating” after the cube gets destroyed.

Also, all these cubes are build by the player so i can’t predict they’re positions. And they can be build in ANY form.

How can i check this? I have no idea my brain doesn’t work right now! I would appreciate any help i can get!

Maybe you can raycast to see if the cube is standing on another cube ?

bool IsGrounded(){
return Physics.Raycast(transform.position,-Vector3.up, CubeLength);