[SOLVED] How do I check if an object is fully inside another?

I have a basic physics game with a bunch of objects that can be moved in many ways. I want to have certain requirements met in order to beat a level. One of these requirements that I want to implement is as follows: an object must be fully inside of a separate, intangible object in order for the level to be considered “complete.” How can I detect an object being fully inside another?

There’s not really anything that’s going to let you directly detect if the object is within another entirely. A few things you could do:

If sprite objects: Determine the earliest point that object B would be inside object A, and create a custom point there, then use the “Point is inside object” condition and compare that custom point against Object B.

If not sprite objects: Closest I could think of would be an event with 4 conditions (2 X, 2 Y) checking that the object B’s X point is >= than Object A’s X point, and <= Object A’s X point + width, then two more for the Y positions.

Thank you for your quick reply! It is a shame that there is no way to do this directly. I have created my own solution. I placed a set of four points on the object so that there is no way for the points to be inside the zone without the whole of the object, and no way for the whole object to be in the zone without the points. This has worked wonderfully for my square objects. For circles, I will have to think of something else, I believe. Perhaps math will save the day again, but as it is quite late where I am, I will think more tomorrow. Once again, thanks for the quick reply. -Gus

Here is what I would do. It seems straightforward, no points or positions, so I’ll assume I’ve misunderstood the question.

Have an outer zone around the finish zone and use collision conditions. In my drawing the blue circle is the only object that meets the requirements of finishing the level.



@AugustineM399 Can you please define what you mean by ‘inside’?

Do you mean when one object is overlapping another, such that it’s not touching any of the edges (i.e. it’s inside the object’s boundaries)?

Or do you mean where an object is inside, say, a U shape (like a bucket or a cup), so it’s not actually touching the object per se, but can be considered ‘inside’ it (since it’s concave)?

overlapping. @Bubble already solved the problem in a seemingly very effective manner, so I think I will implement their solution, but thank you for your time. -Gus

I can’t believe I didn’t think of this. That is a great idea! Thank you! -Gus
Edit: I have marked the post as [SOLVED] because this solution works wonderfully. ( :

1 Like