UnrealScript Game Programming Cookbook

(Chris Devlin) #1
Chapter 3

83

// Allows the pawn to rotate left and right
DeltaRot.Yaw = PlayerInput.aTurn;
ProcessViewRotation( DeltaTime, ViewRotation, DeltaRot );
SetRotation(ViewRotation);
NewRotation = ViewRotation;

if ( Pawn != None )
Pawn.FaceRotation(NewRotation, deltatime);
}

Let's focus on the important change that we've made within that block of code:
/** Stop the player from adjusting the pitch of the
camera */
DeltaRot.Pitch = 0;
/** Allows the pawn to rotate left and right */
DeltaRot.Yaw = PlayerInput.aTurn;

Our Pitch is set to 0 , just as it was for the side-scroller, because we don't want the
camera or pawn to be able to look up or down.
At the same time, we are tying the yaw of the pawn (and by connection, the camera)
to the yaw of the mouse. If the player moves the mouse left and right, the pawn and
camera will follow.


  1. Our default properties are left empty as shown in the following code snippet:


defaultproperties
{
}


  1. Next up, we need to create our TopDownCam class. Have it extend from Camera as
    shown as follows:
    class TopDownCam extends Camera;

  2. Just as we've done with all of our other cameras, we'll add the code for this. It looks
    identical to the side-scrolling camera. First we'll add our variables as shown in the
    following code snippet:
    /* Hardcoded vector offset we will use, rather than
    tweaking values in the editor's CameraProperties
    /
    var constVector CamOffset;


/** Hardcoded rotator offset we will use, rather than
tweaking values in the editor's CameraProperties */
var constRotator CamOffsetRotation;
Free download pdf