ynef
ynef

Reputation: 107

Check if one GameObject is placed on top of another in Unity

I have two cubes with one being slightly bigger than the other and can be moved around freely around the scene by the user.

I need to know when the user has placed the smaller one on top of the bigger one and then continue with the script.

I understand that I need to check the collision somehow and maybe check the Y coordinate of both boxes too to make sure the user puts the smaller cube on top of the bigger and not vice versa.

How can I do this?

Upvotes: 0

Views: 2023

Answers (1)

Jan van Brügge
Jan van Brügge

Reputation: 772

You could either create a trigger (more on that in the unity docs) and use the respecrive callback to continue or you could constantly check the position of the second object and if the coordinates are above the ones of the big box continue.

Upvotes: 2

Related Questions