Lab 5 - Canvas, Input, Vector Subtract
Summary
You will implement a basic HUD and use Canvas as well as HUD functions to draw objects to the screen according to the state of the player controller.
Learning Outcomes
- Familiarity with Canvas and how to learn more about it
- Familiarity with new inputs
- Essential 3D math
Files to Implement
- L5Game.uc
- L5Player.uc
- L5HUD.uc
- L5-Map.udk
- Update: DefaultInput.ini
Submission Requirements
Show your instructor your working hud and inputs by starting the map, adding some bots using the ] key, updating the counter with the . key, and displaying the correctly working hud on-screen.
Instructions
- Create the script package Lab6 and implement all of the following in it
- Create a game type called L5Game, have it extend the UTDeathmatch class, and associate it with maps with the prefix L5
- Set the player controller class for this game type to be the class L5Player
- Set the hud class for this game type to be the class L5HUD
- Create a basic map with the game type set to L5Game
- Create the class L5Player that extends UTPlayerController
- Add an integer member variable to this class to track how many times IncrementSpecialMessage was called
- Add the exec member function IncrementSpecialMessage to L5Player
- Have this function increment the integer member described above every time this function is called
- Have this function output a debug log message every time it is called so that you know that it was called while developing
- Add a Pawn type member variable named closestPawn to this class to track the closest Pawn that is not this player's pawn
- Every tick (override the function PlayerTick), have this class iterate over all pawns in the world
- Store the closest pawn that is not this player's own in the above member variable
- Add 2 new input bindings to DefaultInput.ini:
- Bind the . (period key, beside comma) to the IncrementSpecialMessage command
- Bind the ] key to the command AddBots 3 (You can copy paste this command)
- Create the class L5HUD that extends the class HUD
- Create a DrawHUD member function to display the following screen features:
- Draw a blue box sized 0.2 of screen width and 0.5 of screen height with the top left positioned at 0.7 of the screen width and 0.1 of the screen height
- If our local player's pawn is not none and the local player's closest enemy pawn is also not none:
- Draw a green 3D line that starts at the player pawn's location and ends at the player's closest enemy pawn's location
- Write text inside the blue box detailing the name of the targeted pawn, something like:
Found close enemy Monarch
- In this case, Monarch is the close enemy pawn's name
- If the local player's special message counter is above 0, write another line of text inside the outline box:
Counter: 21
- In this case, the value beside counter is the value currently contained in the special message counter integer defined above
- Create a DrawHUD member function to display the following screen features:
Your end result should look something like this: