Pushing Objects in Unity to Complete Puzzles
Going over how I implemented the player pushing another GameObject

Objective: Implementing a mechanic for the player to push a GameObject for puzzle completion purposes in my 2.5D game.
Setup
To get things started for today, I added a small cube to be pushed, as well as a smaller cube to act as our pressure pad. This can be seen in the screenshot below:

The Functionality
The overall goal in today’s article is being able to push an object onto a pressure pad to trigger an event. For now, that event will be to simply stop the cube when it is on the pad. As such, the first thing I did was implement the functionality for my cube to moved. I accomplished this with the following code here:

Notice how I grab the RigidBody component of the movable object. This is necessary to move the object. This gave me the result we have below.

With that, we can now check to see if the object made it to the pressure pad. To do this, I created the code we see below in a custom C# script I named PressurePad.

This gave me the following result:

That’s all for today’s article! Thanks for reading! In the next article, I will be going over some files available through GameDevHQ’s Filebase!