Lab 4 Part 2
Summary
In this lab, you will get an introduction to UDK game types, the UnrealScript class hierarchy, Object, Actor, some of the basics of UnrealScript, write a game type, and spawn an actor.
Learning Outcomes
- Knowledge of UnrealScript class hierarcy
- Introduction to UnrealScript and where to find resources to learn more about UnrealScript
- Introduction to game types
- How to write a new game type
- How to write an actor
Files To Implement
- L4Game.uc
- L4PlayerController.uc
- L4-Map.udk
Submission Requirements
Run your map as described above and show your instructor the special message displayed in the log window.
Instructions
Lab prep
You will use some of the skills that you learned in part 1 of this lab. If you forgot how to do something, please go back to part 1 to see how it is done.
Resume your work from github
Last lab, we initialized your lab repository. Today, we will see how we can resume where we left off. Use these instructions every time you need to begin work again on a lab computer. Note that this is only required because the lab computers destroy your local repository when they shut down! On your home computer, you should not need to do this if you completed part 1.
- Open git bash
- Navigate to the root-ish UDK directory (UDK/UDK-2015-01)
- Init a git repo in this directory
- Add your github labs repository as a remote (I will assume that you named your remote origin)
- Fetch from your remote (git fetch origin)
- This will make the local repo aware of the current state of your remote's git database
- Checkout your remote's current master branch (git checkout -f origin/master)
- Notice the -f parameter. This tells checkout to force the checkout. This is required because your repository has files that will overwrite the already existing files and git does not like that. -f forces git to proceed.
- Create a local master so that you can make commits (git checkout -b master)
- Notice that we used the checkout command here. This is slightly confusing but when the -b option is passed to checkout, it merely creates a branch at the current commit and sets the created branch as the current branch.
You should now be exactly where you left off last time.
Lab Instructions
Using the instructions from last lab, do the following:
- Create a package called Lab5 (ensure that you create the correct directory structure!)
- In this package, create two UnrealScript files: L4Game.uc, L4PlayerController.uc
- Open L4Game.uc and update it to extend the class UTGame
- Set the default property PlayerControllerClass equal to class'L4PlayerController'
- This will cause the UDK to use your player controller class
- Set the default property MapPrefixes[0] equal to "L4"
- This, in combination with the in-editor game type setting, will cause the UDK to use your game type when loading the map you will create soon
- Set the default property PlayerControllerClass equal to class'L4PlayerController'
- Open L4PlayerController.uc and update it to extend the class UTPlayerController
- In this class, above the defaultproperties block and after the extends line, create the function PostBeginPlay
- This function does not return anything
- This function does not accept any parameters
- Have this function log out a special message (ie This is a special message)
- After logging out a message, call the super form of this function
- Compile your package (remember, compile in debug!)
- Open the editor by using the command: udk editor -debug
- Create a map in the editor (the basic map template will do), set the game type in the map to your game type (L4Game)
- Save this map as L5-Map.udk somewhere under UDKGame/Content
- Run your map navigating to the UDK binary in the commandline and executing the command: udk L5-Map.udk -log -debug
This should open your map. In the command prompt window, you should see your special message displayed. Ensure that you add and commit all of the files that you created and/or changed in this lab to your labs repository then push! If your L4-Map.udk file is not too large, you can consider adding it too to your repo.