UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Weapons


188

We've changed a few values here from the explosive barrel. Most notably, we use a different
static mesh, and instead of a collision cylinder we use a rough approximation of the mesh's
size. To see the difference during runtime, enter Show Collision into the command line
when running the editor. We've also changed the sound effect.


We didn't have our explosive barrel detonate when touched by the pawn, but we do want that
to occur with the landmine, so we've set that value to TRUE here. We also do not want the
mine to block actors like the barrel did, so we set that to FALSE.


Other than that, our landmine is identical to the explosive barrel. Play with some of the
properties for a bit and see what you're able to create as well!


How it works...


Just as we did with our explosive barrel, we extend our landmine from ExplosiveBarrel,
because we want players to be able to interact with it. We've also made it placeable again,
so that our level editors can manipulate it within the editor.


The Touched() function is the key here too, because it allows detonation to occur either
when a pawn or vehicle touches it, as well as when it takes damage. You may have also
noticed that this function is used pretty frequently within UDK, especially for taking damage.


Finally, we make it easy for our level designers to alter the properties of the Landmine class
by exposing properties such as particles, sound cues, and static meshes within the editor.

Free download pdf