How would I check if two parts are inside of each other?

I am making this game, and I need to check whether or not two parts are inside of each other.

I know that I could use Magnitude, but that would be extremely inefficient.

So what would I do in order to check that?

Please note: I am not asking for anyone to create a script for me, all I really want to know is what I could do to check if they are inside each other.

10 comments

0

Do you mean "inside of each other" in the 3D world (position) or one is the parent of the other (Explorer/2D)?

0

Could use a touched event and in the touch event check if it is touching a particular part you want.

0

I mean inside each other 3D world, yes.

0

@yougottols1 wouldn't that only return whether they were touching each other once? And it wouldn't really give the feedback that OP is looking for.

0

OK, you can probably get the size and position of both the parts and then check to see if the difference between them is less than a certain Vector3 value - does that help?

0

@jjwood1600 That would be inefficient because I am going to use it in a model placement system, with multiple models... there would be way too many values to track.

0

So you're trying to see if the model that you're placing is going to be placed on top of another model, basically?

0

Exactly, so that if it is on top of another model, it will not be placed

0

Why don't you just check to see if the mouse target is the floor?

0

Because if my mouse is in the middle of the model, and I then place the model, the sides of it can be placed on top of another model.