Game Development Reference
In-Depth Information
Getting ready
We're going to make a whole new PlayerController class for this tutorial, as we need
to add a new function to it. Create a new class called TutorialPlayerControllerTDC
(top-down camera) and have it extend from PlayerController . For this recipe we'll be
creating a new player controller class so that our pawn's aim is not affected by the new
camera system we've implemented. Otherwise, our pawn's aim would be way off target
as it would not be using our player's rotation, but our camera's.
class TutorialPlayerControllerTDC extends PlayerController;
How to do it...
The first thing we'll want to do here is to adjust the aiming for our pawn. Without this, our
pawn's aim would follow where our camera is pointed, and not where our pawn is facing.
1.
Let's add the code for that now. This is identical to the code found in
TutorialPlayerControllerSSC.uc .
/********************************************************* * USED
FOR ALL CAMERAS ***
* Rotator where the pawn will be aiming the weapon.
* Will be different, depending on which camera system we
are using
**********************************************************/
function Rotator GetAdjustedAimFor(Weapon W, vector StartFireLoc)
{
returnPawn.GetBaseAimRotation();
}
2.
The next part is nearly identical to that in the side-scrolling camera as well, and is the
only change we've made to this class. Add the following code, then I'll explain:
/**********************************************************
* Forces the weapon to fire in the direction the pawn is
facing
**********************************************************/
function UpdateRotation( float DeltaTime )
{
local Rotator DeltaRot, newRotation, ViewRotation;
ViewRotation = Rotation;
// Stop the player from adjusting the pitch of the camera
DeltaRot.Pitch = 0;
 
Search Nedrilad ::




Custom Search