1.0 creating a pressure plate

To illustrate some of uses of the UDK physics system we'll be creating a simple pressure plate.  This will use a constraint to keep the plate moving only up and down, a thrust actor to push the plate up, and a crate that can weigh the plate down.  We will also create a trigger that can sense the pressure plate being pushed down and send a message through kismet.

Creating a Rigid Body
For the rigid body crate I've imported a static mesh cube, it's 128x128.  By double clicking on the cube in the content browser we can attaching collision to it.

Reference: Image 1

Adding a Rigid Body to the Level
Select the static mesh cube and right-click on the floor in the perspective window.  Select Add Rigid Body: your_mesh_name, and place the rigid body actor in the level.  We can run the game now, and using the physics gun, move it around the level.  To use the physics gun hit-tilde ` for console, then physicsgun, then mouse wheel down to the gun.  Right-Mouse will drag an object around.

Reference: Image 2

Creating a Pressure Plate
For the pressure plate mesh, I've created a BSP model then converted it into a static mesh.  This allows for getting the game play prototyped before modeling an object in an art package.

bsp (3): converting to static mesh:

Changing the Mass Scale of the Plate
Add collision to the new mesh, and while in the static mesh editor, dial back the Mass Scale to .5 (the plate is large and we'll want it's mass to be small enough for the smaller crate to move).

Reference: Image 3

Placing the Pressure Plate
I've created a depression to place the pressure plate in, and placed the plate half way between the top height I want it to move, and the bottom of the depression.  This will allow us to constrain the pressure plate by distance from its original positional origin.

If we run the game now, our pressure plate will sleep, suspended at its original location.  If we bump or shoot it, it will fall to the bottom of the depression.

Reference: Image 4

Adding Upward Thrust
Goto the actor class window and select an RB_Thruster Actor and place it in the level.

View > Actor Classes > RigidBodyBase > RB_ConstraintActor > RB_Thruster

First move the thrust actor to directly above the pressure plate's pivot point.

Rotate the thruster until the yellow thrust arrow is facing down.   This will give us a negative z thrust.

Double-Click or use F4 to open the thruster properties and set the thrust around 600 (dependent on your pressure plate mass).

Now right-click the lock button on the top of the properties window.  This will lock the current properties window to the current actor and allow us to select another actor with the window open.

Select the pressure plate and using the green arrow under the Attachment menu attach the pressure plate to the thruster object. (I usually use Hard Attach Option for things like this, but honestly I'm not sure if it matters.)

Reference: Image 5

Constraining the Pressure plate
If we run the game as it is currently, and we are facing the pressure plate as the level starts up, the pressure plate should fly straight up into the air, due to the constant thrust.  If we set the thrust a little lower (say 435) we can get some shots at it, it will rotate the plate causing it to fly off into the distance.  After playing around, set the thrust back to 600.

So we need to constrain the pressure plate to move only in the z-axis, and limit how far it can move upward.  This can be accomplished by adding a RB_PrismaticActor.

Actor Classes > RigidBodyBase > RB_ConstraintActor > RB_PrismaticActor.

Move the prismatic joint over the pressure plate and open the actor properties.  Under the RB_ConstraintActor propererties add the pressure plate to Constraint Actor 2, using the lock button to lock the properties to the prismatic actor. Leaving the Constraint Actor 1 set to none will anchor the prismatic joint to the world, which is what we want. plate to the prismatic joint using the lock button, as above.  Now open the Linear menu under RB_ConstraintActor and set the Linear XSetup to bLimited = 1,then set the Linear ySetup to bLimited = 1.

If we run the game now, with Linear ZSetup to bLimited = 0, the pressure plate will only move in the x-axis, which is what we want.  But the pressure plate still rises without stopping.

Setting the Linear ZSetup to bLimited = 1 and adding in a distance to the limit size will stop the plate at the specified distance from its starting point.  In this case I am using 48.

Reference: Image 6

Adding an Activated Message
We now have the physics functionality we want.  In Game, we can move the cube onto the plate and the plate will sink.  Remove the cube and the plate will rise.

There are a couple of things to do to get a message when the plate is depressed, allowing something in our level to be activated by the plate.

First let's add a little trigger below the plate.  See trigger volumes if this is new to you.  Make the trigger volume at the bottom of the depression, so that the pressure plate only touches the trigger when depressed.

Reference: Image 7

There are a couple of settings within the rigid body actor that we will need to set to make this set up work properly.

Open the KActor's properties and set:

No Encroach Check [false or unchecked] - This allows triggers to react to this rigid body
Can Step Up On [true] - This allows actors to walk up onto which with our platform sticking out a little from the ground will help smooth things out

Pawn Can Base On [true] - This prevents players from bouncing on top of the pressure plate.
Safe Base If Asleep [false] - This will allow the plate to keep moving if a pawn is on top of it.

Reference: Image 8

Now in kismet we can add a touch event to the trigger.

By default triggers are set to not react to KActors which includes our rigid body.  There are actually a few settings within the trigger that will need to be set to get a touch event to trigger when the pressure plate collides with the trigger volume.

In the touch event properties window:

ClassProximity Types:
> KActor (This field controls what actor types a touch event will occur for)

Force Overlapping [false! damn you field] (If true this event only triggers if there is a player in the trigger.  It took me awhile to find this out....)

Max Trigger Count [0] (Allows the event to fire an infinite number of times)
Player Only [false] (!!!)

Reference: Image 9

Testing the Pressure Plate
For now we just need to find out if everything is working.  Hook up a couple of log events to the Touched and Untouched, output them to screen and include some comments for verification.

Run the game, move the Cube onto the pressure plate.  You should a comment on screen when the plate reaches the trigger.