UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 4

99

How it works...


All game-related objects are derived from the base class, Actor, in the Unreal Engine.
ActorComponents define numerous lightweight components that provide an interface
for modularity of actor collision and rendering. An ActorComponent object is an object
which can be attached to an actor, and subclass can override some or all of the default
properties of the component.


In this example, we're adding a particle component to our pickup, which allows for the
viewing and alteration of particles when the pickup is spawned.


We've also added a component for our base mesh, which allows us to easily swap out the
static resting beneath our pickup. Both of these aesthetic changes can make it easy for
players to discern what purpose a pickup serves from a distance (that is, health, armor,
weapons, and so on).


Animating our pickup


Our pickup is moving towards almost completed, but there are a few more additions we can
make to it, to allow for a bit more life behind breathe life into our object. Let's add a rotation
and bob to our pickup, so that it really grabs our eye with some animation.


Getting ready


Open up your Tut_AmmoPickup class in your IDE and we can begin.


How to do it...


This is very straightforward. We start off by adding a rotation to our pickup, and then add an
animated bobbing motion. Just as we did with our previous tutorials, we'll need to alter our
defaultproperties block as explained in the following steps:



  1. In the defaultproperties block write the following code:
    defaultproperties
    {
    ....
    / If true, our pickup will rotation in place */
    bRotatingPickup=true
    /* How quickly the pickup rotates /
    YawRotationRate=16384
    /
    if true, the pickup mesh floats (bobs) slightly */
    bFloatingPickup=true

Free download pdf