UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Crafting Pickups


92

Creating our first pickup


We're going to create our first pickup by extending from one of the excellent ones already
provided by UDK. In this case, we'll be extending from UTAmmoPickupFactory to create
our own ammo pickup.


Getting ready


We'll need to open up our IDE and create a new class extending from our
UTAmmoPickupFactory class.


class Tut_AmmoPickup extends UTAmmoPickupFactory

Afterwards we'll make some tweaks so that it suits our needs, and the tutorials that follow
will really make this a personalized pickup, as we adjust a pawn's desire to head towards it,
the animations it performs, and who can and cannot pick it up.


Now that we've got a class extending from UTAmmoPickupFactory, we've also inherited
all of that class's properties, including its functionality. For this recipe, we won't have to
make any changes to the functions, but we will be altering some of its default properties.


We won't need every category in our class to be accessible within the editor once we
create an archetype for the class, so let's clean things up by adding the following code
to keep things neat:


// Hides categories that we won't be needing from the archetype
HideCategories(Object, Debug, Advanced, Mobile, Physics);

You'll also need to remove the semicolon (;) from your class declaration,
otherwise you'll receive an error. The top of your class should now read
as follows:
Class Tut_AmmoPickup extends UTAmmoPickupFactory
For reference, all of our classes will be saved under the following directory:
C:\UDK\July\Development\Src\Tutorial
It follows the format given next:
HardDrive\UDK\MonthOfTheBuild\Development\Src\
FolderName
Free download pdf