Game Development Reference
In-Depth Information
This next bit seems long-winded, but it is essentially one function (really, a state) that
we are overriding from Pawn.uc . It is identical to the one found in that class, except
that we are altering this bit of code:
/** The only change for the side scrolling camera to this
function. Update acceleration - pawn can only move forward and
back now */
NewAccel.Y = -1 * PlayerInput.aStrafe * DeltaTime * 100 *
/** Set to 0 to not allow movement on the X or Z axes */
NewAccel.X = 0;
NewAccel.Z = 0;
This controls the movement of our pawn, based on the direction it is facing. Hitting
the left and right (or A and D ) keys on the keyboard will now force your pawn to move
forward and back across the screen. Previously, you would have to hit the up and
down keys to make the pawn move forward and back.
Moreover, setting NewAccel to 0 on both the X and Z axes prevents the pawn from
strafing left and right. With our plane of movement locked, we can now create a true
In the following code, we are overriding the state, PlayerWalking , found in the
PlayerController.uc class. Our goal is to update the acceleration to allow only
forward/back movement.
* Player movement, overriding the one found in
* We are updating the acceleration to allow for only
forward/back movement
state PlayerWalking
ignores SeePlayer, HearNoise, Bump;
function PlayerMove(floatDeltaTime)
localvector X,Y,Z, NewAccel;
localeDoubleClickDir DoubleClickMove;
localrotator OldRotation;
localbool bSaveJump;
Search Nedrilad ::

Custom Search