Box mechanic: Is it possible to know when the box is closed on all margins?

Update 2: I have come up with a solution but I need to know how could I make my AI look into a direction and find the closest object (by tag) to it then calculate the distance to it and repeat the step a couple of times. I will post another question for this particular issue and close this one when I have a proper solution.

Update: I have tried using OverlapSphere to count the collisions – doesn’t work as it sometimes can count more than needed.

I have tried using a box collider around the AI – same as above.

I have tried making 4 colliders in 4 direction attached to the AI to check for collisions on directions – also same as above.

Reopened as I’ve found out that my solution will not provide me with the feature that I want and would become to complex at a point.

Please provide me with any other solutions you may think about!

Hello,

This is going to be a pretty big question. I hope it’s not something very hard to do, honestly.

I want a mechanic like this (i already have it – kinda):

12295-box_find.png

When I click on the screen, the **Start Point** is created and it instantiates a line/fence, the last piece is considered an **End Spot** which offer three possibilities of continuing -- *any of the other three directions*

I’d like to know how could I check if a closed box is created through this mechanic? I want something to happen when the box is closed, how should I go about in doing so? Any info, even tutorials for things that could get me here will receive thumbs up ^_^.

Thanks a lot for any help!

If this is a game, I’d have things crawling along the edges – a simple ray cast & turn left on a hit movement script. Have them ignore each other so they can crawl clock and counterclock-wise, some fast (may miss small gaps) and some slow. They all want to flee off the edge of the map or something. They may be trying to get in or out.

Say the goal is to protect some candy inside the box, which respawns (and you lose points) when it’s eaten. You won’t know the box is sealed, but if they can’t get in or find it difficult to get in, you get lots of candy points, so who cares.

The end may not be exactly what you were thinking, but, especially in a game, it never is.