Lab 6 - Camera Manipulation
Summary
In this lab, you will implement a pawn and a player controller that will allow you to control the position and direction of the camera.
Learning Outcomes
Files to Implement
- L6Game.uc
- L6Pawn.uc
- L6PlayerController.uc
- L6-Map.udk
- Update: DefaultInput.ini
Submission Requirements
Show your instructor that you can manipulate the camera's three rotational components with keys on the keyboard individually and that you can manipulate the camera's three positional components with keys on the keyboard individually. Finally show that you can lock and unlock the camera.
Instructions
- Create a script package called Lab6 and implement the following classes in it
L6Game
- Create a game type called L6Game that extends UTGame
- As usual with game types that extends UTGame, be careful to set the MapPrefixes[0] entry appropriately
- For this lab, set the MapPrefixes[0] entry in the defaultproperties to "L6"
- We will need to link up our player controller and pawn classes to this game type
- Set the PlayerControllerClass property to the class L6PlayerController
- Set the DefaultPawnClass property to the class L6Pawn
L6-Map.udk
- Create the map L6-Map.udk and set its gametype to L6Game. You can only do this once you are able to successfully compile the Lab6 package including the L6Game class.
L6Pawn
- This pawn class will have code to explicitly control the camera. This class should extend UTPawn
- Add the following member variables:
- bool L6CamLocked
- Should default to false
- vector L6CamOffset
- Should default to (X=200, Y=0, Z=100)
- rotator L6CamRot
- bool L6CamLocked
- Override the function: simulated function bool CalcCamera( float fDeltaTime, out vector out_CamLoc, out rotator out_CamRot, out float out_FOV ) and implement it as follows:
- Set out_camLoc to be the sum of this pawn's location and L6CamOffset
- Branch: If L6CamLocked is true...
- Set out_CamRot to be a rotator casted from a vector that is the result of subtracting out_CamLoc from this pawn's location
- If L6CamLocked is false...
- Set out_CamRot to be equal to L6CamRot
- Return true
L6PlayerController
- This player controller class will update its L6Pawn's camera explicitly
- This class should extend UTPlayerController
- Initialize the inherited member variable bBehindView to true
- Implement the exec function ToggleCamLocked
- This function should check if this controller is attached to an L6Pawn
- If it is, it should invert the value of the pawn's L6CamLocked variable
- This function should check if this controller is attached to an L6Pawn
- Implement the following exec functions:
* IncCamOffsetX * DecCamOffsetX * IncCamOffsetY * DecCamOffsetY * IncCamOffsetZ * DecCamOffsetZ
- These functions should check if the controller is attached to an L6Pawn
- If it is, they should update the pawn's L6CamOffset variable
- The *X, *Y, *Z functions should update the X, Y, or Z property of L6CamOffset respectively
- The Inc* functions should increment the property by an amount (eg 100)
- The Dec* functions should decrement the property by an amount (eg -100)
- These functions should check if the controller is attached to an L6Pawn
- Implement the following exec functions:
* IncCamRotPitch * DecCamRotPitch * IncCamRotYaw * DecCamRotYaw * IncCamRotRoll * DecCamRotRoll
- These functions should act similarly to the offset functions above in concept, except that they should update the L6CamRot property instead
- The properties in a rotator are Pitch, Yaw, and Roll. The functions above should update them respectively.
- The Inc functions should increase their property by an amount eg 2500
- The Dec functions should decrease their property by an amount eg -2500
Update DefaultInput.ini
- Add a keyboard input for each of the exec functions implemented in L6PlayerController
- Recommended:
- Use the numpad keys - 1, 2, 4, 5, 7, 8 for camoffset functions
- Use insert, delete, home, end, pageup, pagedown for camrot functions
- Use numpad key 9 for the ToggleCamLock function
- Recommended: