Detecting collision on specific sides

I’m a beginner fumbling my way through learning this, so I appreciate any help.

I have a pushable block, and when it bumps up against another block that blocks all, I need to see which sides are no longer pushable. Ex…

So if I push the pushable block upward, and it collides on the top side with the block block, I need to know that, so that it can no longer be pushed up. I’ve tried a variety of things, and with what little knowledge I have at the moment, the only way I can conceive of doing it is a very LONG and convoluted set of if branches. Which is kinda gross. X D

I need to detect on all sides so that the next time it makes the check to be able to be moved or not, it knows “Okay, I’ve got blockable objects above, left, and below me. I can no longer be moved anywhere but to the right.”

Any advice is greatly appreciated!

P.S. For thoroughness sake, here is how I have the push block set up, collision box wise :


The box in the middle is the BlockAll collision block.

1: you could do a sphere trace and determine if something in range and on what sides as you will get the transform in the results.

2:quick and dirty option is to put multiple boxes set to overlap all, and the one that DOESNT return a result is an empty space. or the one that DOES return a result is blocked.
to prevent lag in that setup, you’d make the objects sleep and wake them up when you want to test free space, then put them back to sleep…

option 3, create an array and do a lookup, which should be relativley simple in 2d, but if its large it gets trickier.

I’m not quite sure how to implement these strategies, but I think I get the general idea… I’ll play with them today.

if each movement of the block snaps to the grid, then you could just line trace on each side. the line trace returns a bool=true if it hit something.
As the object is about to move, run a line trace in the direction of movement
if the Hit bool returns true, Dont move

Yay! Your second post clarified things a lot. Thank you very much.

yeah sorry about that, the first answer i gave was pointing you in the wrong direction.