Friday, October 14, 2011

Pawn Class (UnrealScript)

The Pawn class is used to physically represent the players, characters and creatures in the Unreal Engine. It contains functionality for dealing with 3D models (Mesh), animation, collision, damage, physics, weapons, sound...

An object of type Pawn can be controlled by a player or by Artificial Intelligence. This control is encapsulated in a class of type Controller and is indifferent to the Pawn class. In the next article we will see the use of the Controller class.

There are several subclasses of Pawn in the Unreal Engine as seen in the image below. We can see that the Pawn class is also used to create vehicles. Classes that begin with UT contains the implementations for the game Unreal Tournament.

I did a very simple example to illustrate the use of the Pawn class. I create a subclass of UTPawn class that can be place by the editor. I added a SkeletalMeshComponent (3D model with animation) and set the properties required for the animation. Then, I define that my class will be controlled by a Controller class of type UTBot.

class TestPawn extends UTPawn

   begin object class=SkeletalMeshComponent Name=Model3D                
   end object


This screenshot is from my test using this class and running on the UDK Editor: