Obtaining a trigger event off a RigidBody

It is possible to cause a Trigger event to only fire off upon contact with a RigidBody thrown around in the scene under physics. This would be good in a case where a door at the bottom of some stairs is locked and you can't open it. Tipping over a fridge so it falls down some stairs under physics to break the locked door would offer a plausible solution and a good game play challenge.

How to do it...

  1. Create a basic scene using the Midday Lighting map template. Set the GameType for PIE to UTGame. This is done through View | World Properties under Game Type.
  2. Ensure the scene has a Trigger and a Mover at the same location animated by a Matinee action. The Matinee will be set to play when the Trigger is touched, so you'll need to add a Trigger Touch event in Kismet, but we want it so the player doesn't launch this event. So in the Trigger Touch event properties turn off Player Only.
  3. In the Trigger Touch event's properties set the entry for Class Proximity Types to KActor, since we want the RigidBody to trigger the event. In the Ignore types, include an entry Pawn. Also tick on the checkbox for the property Use Instigator.
  4. In the Content Browser locate a StaticMesh that would be good to bounce around the scene. A crate or box would suffice, something like PacktKismet.Mesh.BlockMover. Highlight the asset you chose, and in the Perspective viewport right-click and choose Add Rigid Body: BlockMover. A RigidBody actor is named in the scene as a KActor (or kinematics actor) and can perform under physics.
  5. Select the added KActor in the scene, then in Kismet, under the Instigator nub of the Trigger Touch event right-click and choose Create New Object Variable using KActor_0.
  6. Hook the Object Variable Kactor_0 up to the Instigator nub of the Trigger Touch event.
  7. In the editor, with the KActor still selected, press F4 to edit its properties. Ensure that the Collision Type property is COLLIDE_BlockAll.
  8. Also ensure that No Encroach Check is ticked off, since, as it says in the mouse roll-over note: If you want touched events from triggers or volumes, you need to set this to FALSE.
  9. Now you can throw the object around in the scene and bang it on the Trigger to see if it will set off the Mover. You will have to use a physicsgun to do so. Remember to ensure that a player can't open the door directly.

How it works

The PhysicsGun is obtained in UTGame by scrolling the mouse, which is why we specified UTGame at the start of the recipe. The idea of this recipe is to edit the Trigger Touch event so there's a set type of actor assigned to flip it. For this case, we make the default Player Only setting to be ignored and set KActor as what it responds to. It can be both, so to only allow KActor we must set Pawn to be ignored, since the player is a pawn. When you convert a model to be a rigid body its collision type may be discarded and you will have to manually re-assign it to COLLIDE_BlockAll. Its easy to overlook that a touch occurs when the trigger and KActor encroach on each other, but by default the KActor doesn't have an encroach check enabled. No Encroach Check is on by default. So we must turn this off in its properties. The remaining part is to use an Instigator for the Trigger Touch event, defined by the Object Variable KActor_0.

There is a guide I made about this topic on YouTube (you4tom): http://youtu.be/vNtenIWzEbQ?hd=1. The next image is a screen grab from the video, where the ball under the PhysicsGun cross-hair is the RigidBody used to trigger the door:

How it works
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.149.214.32