Custom Vehicle Pickup Factory – Part 1

The code below is very similar to that of any pickup in UDK. I start by extending from UTAmmoPickupFactory, which gives the base characteristics we’ll be using. Although the class I’ve created is annoted pretty well within the class itself, I’ll explain in further detail. We’ll begin by describing the default properties.The default properties is for the most part the part of the code that defines the most common things we need.

[code]
 //TELLS YOU HOW MUCH AMMO IT WILL DELIVER.
 AmmoAmount=10
 //TELLS YOU WHICH WEAPON IT IS ADDING AMMO FOR.
 TargetWeapon=class’UTVWeap_ScorpionTestTurret’
 PickupSound=SoundCue’A_Pickups.Ammo.Cue.A_Pickup_Ammo_Rocket_Cue’
 MaxDesireability=0.3
 //MAKES THE PICKUP ROTATE!
 bRotatingPickup=True
 //YOU GUESSED IT – HOW LONG (IN SEC) UNTIL AMMO RESPAWNS)
 RespawnTime=5.000000
 //EFFECTS HOW THE PICKUP BOBS UP AND DOWN
 BobSpeed=2.0
 BobOffset=5.0
[/code]

By swapping out the TargetWeapon=class with another class, you can tell the pickup  which weapon it is providing ammunition for. The MaxDesireability value tells the AI how important an item is, and whether or not it will take preference for going after this item more than any other. For example, if we have a health pack with a value of .7 and an ammo refill with a value of .3, the AI will naturally head towards the health.

The BobSpeed and BobOffset adjust how quickly and how high the item floats up and down. If you choose to instead have a static item, simply remove these properties, or set them both as zero.

[code]
Begin Object Name=CollisionCylinder
 CollisionRadius=30.0
 CollisionHeight=15.6
 End Object
[/code]

From here, we start to develop the different components of the Pickup Factory. Components are just that: parts which make up this class. They can be anything from collision cylinders, to static meshes, particle effects and lighting. You will want to make the collision cylinder slight larger than the mesh itself, especially if you plan on creating a title which relies heavily on vehicles, such as DeathSentence.  We need to begin each component of our factory with “Begin Object” and finish each one with “End Object”, otherwise the class doesn’t know where the properties one component ends and the next begins. From here we define the default properties of our object.

Next up is the Light Environment. This defines how well the light reflects off of the static meshes which make up the script. Without this, you’ll notice that your static meshes appear very dark, probably black. The RBGA values listed above are all floating point numbers (as referenced by the f following each one) and refer to red, blue, green, and alpha (transparent) channels naturally. The actual mesh for the ammo is up next. This is the item which will be floating above the base, and is what disappears when you pick up your ammo.

[code]
Begin Object Name=PickupLightEnvironment
 AmbientGlow=(R=1.0f,G=1.0f,B=1.0f,A=1.0f)
 End Object
[/code]

The AmmoMeshComp is the next piece we’re working with, and this is the static mesh for the actual ammo we will be retrieving. Anytime your vehicle is in short supply and crosses the collision path, it will acquire the ammo and make it disappear until your determined respawn time. Again, the default properties here are the key traits which affect the meshs’ behavior and appearance. The translation uses the X,Y,Z axis to adjust how high or low it floats above the base mesh. The Scale adjusts the size of the mesh within the game, while the MaxDrawDistance dictates when the mesh will disappear from view. The higher the DrawDistance, the longer it stays in view, but at the cost of more system resources. Finally, the ‘Pickups.Ammo_Rockets.Mesh.S_Ammo_RocketLauncher’directs the script to look for this mesh. By simple swapping it out for another mesh you can change the appearance from something like the rocket, to bullets, or fuel cells.

[code]

Begin Object Name=AmmoMeshComp
StaticMesh=StaticMesh’Pickups.Ammo_Rockets.Mesh.S_Ammo_RocketLauncher’
Rotation=(Roll=16384)
Translation=(X=0.0,Y=0.0,Z=55)
Scale=2.0
MaxDrawDistance=4000
End Object
PickupMesh=AmmoMeshComp
Components.Add(AmmoMeshComp);

[/code]

The PickupBaseMeshComp is equally important, as it is lower most piece of our puzzle. It serves as the base from which our ammunition will float. The properties are similar to those found in the AmmoMesh, however now you’ll see that I’ve lowered the Z value to -10 so that it rests lower than the floating ammo.

[code]

//THIS IS THE BASE, BENEATH THE AMMO
 Begin Object Name=PickupBaseMeshComp
 StaticMesh=StaticMesh’Pickups.Base_Powerup.Mesh.S_Pickups_Base_Powerup01′
 Scale=2.0
 MaxDrawDistance=4000
 Translation=(X=0.0,Y=0.0,Z=-10.0)
 CollideActors=false
  LightEnvironment=PickupLightEnvironment
 End Object
 Components.Add(PickupBaseMeshComp);
[/code]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.