Creating the Pawn
The Pawn class (CustomPawn.uc)
The pawn class is where you store information on the 3d model, special camera modes and other things really related to the physical representation of the actor in the scene. It also holds data related to state the pawn is being on at the moment. For example if your 3d avatar is to feign death, you would put it in this class with a boolean value to test is my player looking dead ?
Create a new file named CustomPawn.uc and change the extend to extend UTPawn. Copy the following code inside.
simulated function name GetDefaultCameraMode( PlayerController RequestedBy )
{
return 'TopDown';
}
/**
* Calculate camera view point, when viewing this actor.
*
* @param fDeltaTime delta time seconds since last update
* @param out_CamLoc Camera Location
* @param out_CamRot Camera Rotation
* @param out_FOV Field of View
*
* @return true if Actor should provide the camera point of view.
*/
simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV )
{
local vector HitNormal;
local float Radius, Height;
GetBoundingCylinder(Radius, Height);
if (Trace(out_CamLoc, HitNormal, Location - vector(out_CamRot) * Radius * 20, Location, false) == None)
{
out_CamLoc = Location - vector(out_CamRot) * Radius * 20;
}
else
{
out_CamLoc = Location + Height * vector(Rotation);
}
return false;
}
/**
* Overriden only to add Camera style TopDown as a FreeCam type, important so the pawn will shoot forward instead of towards the ground
*/
simulated event bool InFreeCam()
{
local PlayerController PC;
PC = PlayerController(Controller);
return (PC != None && PC.PlayerCamera != None && (PC.PlayerCamera.CameraStyle == 'FreeCam' || PC.PlayerCamera.CameraStyle == 'FreeCam_Default' || PC.PlayerCamera.CameraStyle == 'TopDown') );
}
DefaultProperties
{
}
GetDefaultCameraMode will get called by the game player controller when the camera is reset. It will always put you in top down mode. The rest of the functions are to calculate the top down values, you should study them to understand where the camera is placed when it collide with a volume.
This class is relatively straightforward lets go on to the camera class and finish with the HUD and LinkGun.







