Adjusting the player’s weapon aim (Part 1)

At the moment, the player has been set to only fire directly in the direction that the pawn is facing. This would be fine for a completely flat level, but as soon as we add inclines or drops, the player would continue to shoot straight ahead and if facing an uphill slope, the player would shoot directly into the ground, causing any zombie hoards that are a little uphill from the player to be completely safe.

In this prototype, this happens because I fixed the pitch of the pawn aim rotation to 0.

simulated singular event Rotator GetBaseAimRotation()
{
   local rotator   POVRot, tempRot;

   tempRot = Rotation;
   tempRot.Pitch = 0;
   SetRotation(tempRot);
   POVRot = Rotation;
   POVRot.Pitch = 0;

   return POVRot;
}

Before I go on, I want to make sure that Pitch, Roll and Yaw are understood so I have made a little diagram.

Pitch Roll and Yaw

Roll, Pitch and Yaw.

Lets start with Roll. Roll affects the X axis, which in UDK is the direction the player is facing (Unless I’m mistaken, various engines and 3d modelling apps use different axis in different ways). Imagine a drill bit rotating. If this were applied to the pawn, it would end up doing cartwheels.

Pitch affects the Y axis and for the purposes of aiming uphill, is the rotation method we are interested in. If you imagine a fighter pilot dive bombing a submarine, he has to change his pitch to fly towards the ground. Look up at your ceiling, the look down at your keyboard, you’ve just pitched your head.

Yaw is something I’ve already tinkered with. Yaw affects the Z axis and we have used yaw to enable the player to face the direction of the dual sticks. Look behind you, your body and head have just changed their yaw.

 

 

This entry was posted in UDK and tagged . Bookmark the permalink.