This tutorial will be moved over to Hourences.com in a number of months. November 11, 2009

  • Introduction

  • This tutorial will explain you
    This is a large and extensive tutorial. This is not a development tutorial per-se. The focus is largely on how to quickly set everything up for your own game and give you a basic introduction to all the elements involved in making a UDK game. The UDN has dozens of great tutorials for more in-depth information..


  • Folders

  • There are four main folders.
    • Binaries - This contains the game exe, the UnrealFrontEnd, and any additional programs. You are not suppose to modify this folder for your game (small exceptions here and there).
    • Development - This contains the source code for your Unrealscript files. Very important directory. The game will take the source code (uc Files) found in this directory and compile the U file from these.
    • Engine - These are files required by the engine. These files should not be touched.
    • UTGame - These are all the files for your game. You will do most of the work in this directory.
    Within UTGame you have the following important folders.
    • Config - Holds ini files. These ini files determine a great deal and are of vital importance.
    • Content - These are the actual levels, models, sounds, and so on for the game. Also of vital importance.
    • Localization - This holds files with all the dialog text, menu text, and so on. Basically all text.
    • Movies - These are intro movies, and loading screen movies. These are Bink movies.
    • Script - This is where compiled Unrealscript code ends up in.
    • Splash - This is the location of the splash image.
    The other folders in UTGame are not important. If you want to set up SVN or similar, you should add the "Development" folder, and all above mentioned "UTGame" folders.

    Within UTGame\Content you can find a great deal of UT3 content. It is best to keep most of this content in since there are some references to these assets. When you package the game later on, it will automatically strip most UT3 content out so there is not much need to manually go delete file by file from the content directory and it overly complicates things, especially for this already very long tutorial. My usual approach is to simply create a folder within Content, with my game's content.
    • UTGame\Content\ExampleGame\Levels
    • UTGame\Content\ExampleGame\UPK
    Two directories, one for levels, and one for UPK files (all other content). You do not require a billion content folders like the UT3 setup. Most games do not have nearly enough files to warrant so many different folders. As example, our game The Ball, with 1.5 GB of data has just 20 UPK files.


  • UnrealScript

  • Thanks to James Tan for the UnrealScript example files, and Markus Arvidsson for additional help.

    Go to the Development\Src\ folder, and create a new folder. For example "MyGame". The name of the folder will become the name of the U file. So if your game is called "Bobby" you would be best to name this folder "Bobby". All unrealscript files within this folder will be compiled into a single U file for the game to use.
    In the folder "MyGame" you create a folder "Classes", and in that folder add the three folders from this zip: MyGameInfo.uc, MyPawn.uc, MyPlayerController.uc




    This is not an Unrealscript tutorial, so we will go through this process pretty fast. The basic idea of Unrealscript is that every actor has a parent actor. A child takes over all functionality and properties of the parent. For example "class MyPawn extends UTPawn;" - Here our new MyPawn uses the UTPawn as a base.
    At the bottom is always a section "DefaultProperties". These are the properties that will also be visible within the editor, and their default values. Again, the real list of properties is much longer than those in the UC files you just made, but you are only required to add those properties that are different from the parent classes. If you do not specify it in the UC file, it will take over the value of the parent. If the parent does not has it specified, it will take it from the parent from the parent. And so on. It is a tree/pyramid.

    Next up, compiling. We first have to make sure the game knows of the existence of what we just added, by adding it to the list of U files to check for. To do so go to UTGame\Config\ and open up DefaultEngine.ini. Find the section "[UnrealEd.EditorEngine]" and add the following line "+EditPackages=MyGame" below the other ones.
      +EditPackages=UTGame
      +EditPackages=UTEditor
      +EditPackages=UTGameContent
      +EditPackages=MyGame
    The order is very important because it determines in what order it will load and compiled.
    This line will make the U file MyGame a file to always load when starting the editor. Turn off read only protection on the file, save and close. It would also be a good idea to delete UTEngine.ini. Doing this will force the engine to create a new UTEngine.ini based on DefaultEngine.ini. Since you just modified the default ini, this will create a modified UTEngine.ini with your changes in it.

    Next up go to Binaries and start UnrealFrontEnd.exe. The Frontend is a very important tool that allows you to do a whole number of things. In this case we will use it to compile our code. In the top toolbar, click on the little arrow on the right of "Make", and click "Full Recompile".


    If all is right, it will mention MyGame in the console, and in UTGame\Script\ you should now have "MyGame.u" when it is finished.


  • Ini files

  • Next up, we are going to make sure the game uses our new gametype and pawn as the default ones.

    Open up UTGame\Config\DefaultGame.ini. Remove read-only on it. And go to the section "[Engine.GameInfo]".
    • Replace "DefaultGame=UTGame.UTDeathmatch" with "DefaultGame=MyGame.MyGameInfo".
    • Replace "PlayerControllerClassName=UTGame.UTPlayerController" with "PlayerControllerClassName=MyGame.MyPlayerController"
    Save. Delete UTGame.ini so it will create a new one based on your modified DefaultGame.ini.


  • Level

  • Go to Binaries\Win32 and create a shortcut to UDK.exe. Add the command line "Editor -log" behind it. For example - "G:\UDK\UDKExampleGame\Binaries\Win32\UDK.exe editor -log". Start it.
    Make a super basic level. Right click the BSP Cube button and you will get a pop up to enter the size. Enter 1024 for X, Y, Z, and enable "Hollow?". Next up click "Add" in the left toolbar.


    Fly into the cube. Right click the floor - Add Actor - Add Playerstart.


    Do this again, but now add a Light, and move the light to the middle of the room.
    Save the level. I named mine "MG-ExampleGameLevel", and that prefix is important. In MyGameInfo.UC "MG" was specified as being the prefix. Without that prefix the game will not know what gametype to use for it.

    Then, rebuild the level. Top menu - Build - Build All.


    Go to the top menu again. View - World Properties. Expand WorldInfo in the pop up window and find Game Type For PIE. Change this to MyGameInfo. PIE stands for Play-In-Editor, so this determines what gametype to use while playing in the editor.

    And now right click - Play From Here and observe your wonderful level and game!



  • Menu

  • As for the menu, that is actually a level too. A menu is a level that is loaded on start up. That level then has Kismet that freezes the player, and pops up interface elements. That's it.
    Take your existing level, and duplicate it. Save as "ExampleGameFrontEnd".
    Next up, creating the UI Scene. To do this, we will also create our first package. Go to the content browser, and in the bottom left click New. Fill in the package name and name of the UI Scene. Be sure to select UI Scene as the Factory.


    Double click the UI Scene it created if it does not open up the UI Scene editor by itself already.

    Right click anywhere in the screen - Place Widget - Button [Standard]. Rescale the button since it covers the entire screen by default (the green edge is the screen).

    Now to actually make it do something we are going to use UI Kismet. This is actually not entirely the proper way. The proper way would be to make the button do something using UnrealScript. Kismet however works just as well, and it is easier to do so we stick with that for this tutorial.
    Right click the button - Unreal Kismet Editor.


    In Global Sequence, add New Event - UI - On Click, and New Action - Level - Activate Level Event.


    And hook those up.


    In Activate Level Event, add a unique Event Name. I have "OpenYourLevel". When someone clicks the button it will now send out an event to the level. The level will then use that event, and look in its own Kismet what event corresponds to that "Event Name", and do whatever is hooked up to it. In our case that would be a console command to load the next level. As you can see it is bit of a hack, the UnrealScript is cleaner but far harder.

    One last thing before we are done with this UIScene. Click somewhere in an empty space to get the properties of the UIScene itself pop up in the top right. Go to Flags - Pause Game While Active. Disable this. This would stop the kismet script from running, plus if you would build a decent background level this would also stop all animations you may add into it. You wouldn't want that.


    Save your package. Packages must be manually saved or changes will be lost! Save it in the directory you made, so in my example that is UTGame\Content\ExampleGameContent\UPK.

    Now hook this event into your level. Open the Level Kismet (green K in the top toolbar), and somewhere in the empty space add New Action - UI SceneS - Open Scene. Hook it up to Level Startup (New Event - Level Startup). And add the UI Scene you made to the properties of the Open Scene.

    Update: Level Startup will be automatically renamed to Level Loaded next time you open the editor. Just for your information. Feel free to use New Event - Level Loaded right away too.



    Add New Event - Remote Event, and a New Action - Misc - Console Command. In the Remote Event, add the same Event Name as you specified for the button, "OpenYourLevel" in my example. In the Console Command add a new command "open MG-examplegamelevel" - or whatever your playable level is called. This event will be run when the button is pressed, and through a console command it will load your level.
    Now add an Action - Toggle - Toggle Cinematic Mode, and an Variable - Player and hook them up as in the screenshot. This will freeze the player on level start up.

    Even better would be to use a matinee to also start a cutscene as soon as the level starts. Check out the Cutscene tutorial on Hourences.com for info on how to. You can build any kind of 3D background environment in this level, or you can simply overlay the entire screen with a piece of 2D art if that is what you want.

    You are done! Note that this will not function in the editor. The editor does not allow you to run an "Open" console command.


  • Localization

  • Localization files contain all text from the game. To change the language of the game all you need to do is direct the game to another language file. That is the reasoning behind the Localization directory. We will set up an extremely simple INT file for "International" (aka English), with two lines of text.
    I usually just delete all the INT files currently in the Localization folder, and start over from scratch. This will break the UT3 demo so if you were still planning on using that one don't do this.
    First of all, close the editor. The editor only detects INT files on startup. It would not detect any INT file you create unless you restart it. Be sure to save both the level and the package!

    Make a TXT file, and rename it to "MyGame.int". Then add
      [ExampleOfASection]
      01=Most Awesome Title Ever
      02=To play click the button

    The word between the brackets determine a section. Helps to organize things. The 01 and 02 determine the lines in that section. You don't really have to use numbers, it could be anything really.

    Open the editor again, and open your level and interface package again. Open the UI Scene you made again. Right click - Place Widget - Label [Standard], and then do this a second time so you have two. Place them somewhere, and click one of them and look in the top right for its properties. Go to Data - Data Source - Mark Up String



    Add "<strings:mygame.ExampleOfASection.01>" to Mark Up String.

    This is NameOfIntFile.NameOfSection.NameOfLine.

    You can do this another time for the second label. If you change the line in the INT file, it will follow along in the game/editor.


  • Ini Files - More Fun

  • Lets go back to the ini files and fix up some more. Close the editor. You cannot change ini files while having the editor run!

    Open up DefaultEngine.ini - section [URL]
    • MapExt=udk - You don't have to change this, but if you would want to change the extension of your levels, it is this easy really.
    • Map=UTFrontEnd.udk - Change this into ExampleGameFrontEnd instead. This will make it load your menu level by default.
    • LocalMap=UTFrontEnd.udk - Likewise
    Section [Engine.PackagesToAlwaysCook], add "+Package=ExampleGameFrontEnd". This will make the UnrealFrontEnd always cook this file.

    Section [Engine.StartupPackages], add "+Package=MyGameInterface". This will make the game always load this package. You don't do this for every package. Especially packages with interface elements are prime candidates for this. The rest does not need to be in this list.

    Section [Engine.PackagesToForceCookPerMap], Add ".Map=ExampleGameFrontend", immediatelyfollowed by ".Package=MyGameInterface." This will force the package into the level specified above, and only into that level. Again it are mainly packages with interface elements that should be forced into a level. Sometimes a level fails to load an assets, force cooking them into the level solves that issue.

    Optionally, section [FullScreenMovie], this is where start up movies and loading screen movies are specified.

    You are done. Remove UTEngine.ini again to make it reset to your changed DefaultEngine.ini instead.

    Start up the game, and verify that it loads your level, and that pressing the button makes it load your level.


  • Cooking

  • Then, cooking. Kind of a funny name for a very important process. Cooking is basically like a final compile. It makes the content consumer ready.
    Cooking will also combine all your content packages into just a few files, a process that will also protect your content. It is impossible, or at least difficult, to extract things out of a cooked and combined package.

    To kick off the process, open up the UnrealFrontEnd.exe again (Binaries Folder), and in the top left, notice the tab (not the button) "Cooking", click it, and notice the field "Maps to cook". Type the name of your single level here, "MG-ExampleGameLevel". You do not need to enter the "ExampleGameFrontEnd" level here. Remember, you already set that one to "AlwaysCook" in the ini file.


    Next up, simply click Cook on the top toolbar.

    When it is done, it will have created a folder UTGame\CookedPC. The content in this folder is what will be distributed to the consumer.


  • Packaging

  • In the UnrealFrontEnd.exe, click "Package Game" and enter the name of your game. After a few minutes look in the main directory, and you will find your consumer ready packaged game with installer. You are done!


  • Troubleshooting

    • Verify that you did not make any typos.
    • You cannot modify ini files while the game or the editor are running. If you did this, it will have likely ignored your changes.
    • Verify that you have the compiled U file in UTGame\Script\
    • Understand that Unreal needs unique and simple file names. Spaces in names, non standard characters, and duplicate file names should be avoided at all costs. Unreal cannot see the difference between the level "Doghouse.udk" and the content package "Doghouse.upk". It does not see file extensions! All names must be unique!
    • Run the game with "-log" or check UTGame\Logs\Launch.log and read through it. If the game hangs on loading screen, try to find the section where it started loading and look for clues.
    • Your level must be named "MG-NameOfYourLevel". The prefix is important as mentioned before.
    • If during compiling your uc files you get "Superclass errors" you placed the line "+EditPackages=MyGame" in the wrong place. The order is important, it must at the bottom of the list in the ini file. See the relevant section in the tutorial.

    Dozens more Unreal Engine 3 tutorials