UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Crafting Pickups


100

/** How fast should it bob */
BobSpeed=1.0
/** How far to bob. It will go from +/- this number */
BobOffset=5.0

}


  1. Your pickup will now rotate in place, based on the pivot point of your static mesh.
    Adjust the rotation rate to a number that best suits your needs by adjusting the
    rotation rate. This will also allow our pickup to bob up and down.


Static meshes may not always have their pivot point centered on the object
(that is, a door generally uses a corner) so you may have to offset yours a
bit. You can edit it with var vector PivotTranslation;.

With the bFloatingPickup set to true our pickup will now bob in place, while BobSpeed
and BobOffset are variables to fine-tune the animation itself. Increasing or decreasing the
offset will force the pickup to drop and raise to lower and higher points respectively, as though
it were riding on a wave.


How it works...


The parent classes of our pickup offer Booleans for whether or not our pickup can be
animated in a number of ways. By default their values are set to false, or off, and we are
simply turning them on. Additionally, we can easily manipulate the animation properties by
adjusting the BobSpeed and BobOffset variables.


Play with some of these values to really create something completely different, like a quickly
spinning pickup that spawns a particle effect when picked up.


Altering what our pickup does


Now that we have a pickup which offers ammo to the player, and know how to alter a
variety of the pickup variables and aesthetics, let's take a moment to create a pickup
that now offers health.


Getting ready


Open up IDE and create a new class called Tut_HealthPickup. Have it extend from
UTHealthPickupFactory.


class Tut_HealthPickup extends UTHealthPickupFactory
Free download pdf