UnrealScript Game Programming Cookbook

(Chris Devlin) #1

Crafting Pickups


94


  1. Next, we need to add the light environment for our pickup. Write this code in your
    defaultproperties block:
    /* Offers a light around our texture so that it can be
    seen within the game and editor
    /
    Begin Object Name=PickupLightEnvironment
    AmbientGlow=(R=1.0f,G=1.0f,B=1.0f,A=1.0f)
    End Object


Without a light environment you would have a very dark texture, and it would be
nearly unrecognizable. We'll use an ambient glow and set all values (red, green,
blue, and alpha (transparency)) to one. If you want more of a washed out look,
feel free to increase the values across the board.

Perhaps you'd like to bask your pickup in a glow that represents the current
environment or atmosphere of a level. If you were in a stage filled with lava
and fire, it may be wise to have a stronger red value than green or blue.
Stages surrounded by water would be best suited to have a blue hue, so
consider raising the blue value.


  1. With our light environment taken care of, we can now add the visible mesh for
    our ammunition.
    /* The static mesh, or object you physically see within
    the editor and game
    /
    Begin Object Name=AmmoMeshComp
    StaticMesh=StaticMesh'Pickups.
    Ammo_Link.Mesh.S_Ammo_LinkGun'


/** Slight offset, to allow for the mesh and base to line on
center */
Translation=(Y=-10.0)

Rotation=(Roll=16384)
End Object

I always thought that the link gun's ammo looked pretty neat, so let's add that in
there. The rotation value does exactly what you would imagine; it rotates the ammo
in place. If you remember from our camera tutorial, UDK uses its own system for
rotation, as illustrated in the camera tutorial.
That's all there is to scripting an ammo pickup. We'll now need to create an archetype
for it in the editor, so that we can place it in a level.
Free download pdf