Creating a Pressure Pad

Adding more depth for your pushable objects

Now that we have created pushable objects, it is time to add another use for them and that is “Pressure Pads”. Pressure pads, as the name already describes is a collision element that checks for moving objects, and when the moving object (ie. Player or moving box) stays in the trigged area for a set duration, it would trigger another sequence (ie. a door opens, or a passage unlocks etc.)

Setting Up the Pressure Pad:

Setting up the pressure pad is rather easy, as long as you create an 3D object that has a type of collider that is set as Trigger.

The pressure pad with an box collider

The Script:

We are going to create a new C# script for the pressure pad. Since the pressure pad is just going to be an Trigger object, it just needs to check for any collision. Since we already have a tag which all pushable objects are under, we can have the Trigger event check for that.

Pushing the 3D box

We also want the pushable box to overlap the pressure pad by a certain set distance before the pressure pad can work. Therefore we need to have an distance variable to calculate the distance of two objects. In this case it will be the pushable box and the pressure pad.

Create a float variable called “Distance” which we are going to check the position of current object (which is the pressure Pad) and also the object stored within the other variable (which is going to the pushable box.)

In another If statement we set the distance constrains to be under 0.05f which then triggers the set conditions. In this scenario, I want two things to happen when the box collides with the pressure pad. 1) I want the pushable box to become Kinematic (which becomes non-interactive). 2) I want the pushable box to change color to allow the player know that the box has triggered the pressure pad properly.

Once that is done, the end result should look like this:



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Simon Truong

Simon Truong

A Designer, an Illustrator and a massive tech geek aspiring to become a professional Unity Developer.