This tutorial will guide you through setting up a development environment for Unreal Script. At the end of the tutorial you will have a set of tools to quickly edit, compile and navigate through the code base of UnrealScript. the tutorial is designed to show you how to setup your environment, ready to follow the Phidget tutorial in UDK.
There are a number of tutorials which guide you through a similar process and show you how to add other basic interactivity into the game to get you started. For exmaple, Allars Awesome Blog has a very good UnrealScript tutorial here. UDK Central also have a very good tutorial which walks you through adding extra interactivity. Credit must go to the previous sites, as I started out with those tutorials.
Once you have completed this tutorial you will be ready to progress onto the Phidget tutorial here.
You Will Need
- UDK (This tutorial is based on the July 2012 version of UDK)
- Visual Studio 2010 Professional: I am using Visual Studio 2010 Pro as I know it works and this is currently the latest version which is compatible with nFringe. I’m sure the express edition would work as well. If you are a College\University student, then check with a faculty member of staff to see if the University is part of DreamSpark. This will allow you to download a whole range of Microsoft development software for free for academic use (not commercial) and continue to use the software after graduation.
- NFringe: This is a plugin for Visual Studio designed for working with UnrealScript files, more info here.
- UncodeX: This is a great little tool for quickly navigating the relationships between UnrealScript classes.
- A regular backup regime. Use whatever you want, but I cant stress enough the value in backing up your work (This is the second version of this website !!!)
Compile the UnrealScript
It is worth running a full compile of the UDK source code, before doing anything else. This wil ensure all the compiled code is up to date. To do this you can use the Unreal Frontend application which is included in the default installation of UDK. Unreal FrontEnd is a tool for performing common tasks in UDK such as:
- Launching a game
- Starting servers
- Adding clients to a server for local servers
- Running the editor
- Compiling script code
- Cooking data
By using UnrealFrontend to compile your code, you can edit UnrealScript files with any text editor, and then use the Frontend to compile those scripts and run the game.
You can launch the tool from: \Binaries\UnrealFrontend.exe or the shortcut in the Start Menu. Then click SCRIPT then FULL RECOMPILE. As you are editing your own code, you should click the FULL RECOMPILE button every so often to check for compile errors, try to get in the habit of doing this regularly as it makes tracking errors a lot easier when you are only dealing with small amounts of new code.
When the compile process is complete you should receive a success message. As this will still be a clean installation of UDK and you have not yet changed everything, it is highly unlikely that you will receive any errors.
Install the Tools
I will assume you have downloaded and installed UDK. The UDK path names in this tutorial are probably going to be different to your own, depending on which version of UDK you are using. Each new version of UDK is installed into a different folder with the format UDK-year-month. This tutorial will use the July 2012 version so is installed into the C:\UDK\UDK-2012-07folder. So remember to substitute my July 2012 folder for your version.
Microsoft Visual Studio
Install Visual Studio 2010 Pro, nothing special to do here, just a standard installtion..
Next, install Nfringe, again, nothing special to do here, just a standard installtion.
Now install UnCodeX which is a great little application for browsing the UnrealScript files and understanding how different files\classes relate to each other. It also provides hyperlinks within each class so that you can navigate the class hierarchy very quickly.This tool requires an extra few steps for the initial setup, as described below:
- Install the UnCodeX application.
- On the first execution after installation you will be asked if you would like to edit the settings, this is a good idea.
- In the Settings window, select SOURCE PATHS, then the ADD button.
- In this tab, add Development\Src to the path list, then click OK.
- You will then be asked to scan the source paths, click YES. UnCodeX will open and the progress bar at the bottom of the window will indicate when the scanning is complete.
- When you add new scripts and inherit from existing classes, you should come into UnCodeX and select TREE | REBUILD AND ANALYUSE TREE in include the new classes.
You will now see the Package tree on the left column, this list is actually pointing to the contents of Development\Src and allow you to browse the contents of those script folders. The middle column shows the class hierarchy, while the right pane shows the source code for the class selected in the class hierarchy. You will notice hyperlinks within the source code on various classes. These links take you to the class definition for that class. This is a very quick way to navigate around the class hierarchy and a great learning tool.
Create a Visual Studio Project
Follow these steps
- Start Visual Studio 2010 Pro
- Select FILE | NEW | PROJECT
- In INSTALLED TEMPLATES select UNREALSCRIPT
- Select UNREALENGINE 3 LICENSEE PROJECT as the template
- Untick the CREATE DIRECTORY FOR SOLUTION option.
- Enter My_Game as the project name
- Set the LOCATION to the \Development\Src folder within your UDK installation folder
- Click OK to create the project
Move Project Files
Close Visual Studio, and use Windows Explorer to move to the project folder just created by Visual Studio, in this example it will be C:\UDK\UDK-2012-07\Development\Src\My_Game. Select both of the following files:
and move them to the parent folder, ie: C:\UDK\UDK-2012-07\Development\Src this will allow the Visula Studio project to find all the UnrealScript code which will then appear automatically in the Project Properties pane in visual Studio.
To start the project double click on the .sln file you just moved. You dont have to do this everytime, as the project will now appear in the ‘Recent Projects’ Menu in Visual Studio.
Configure the project
When the project is open:
Right click on the project name My_Game in the Solution Explorer and click PROPERTIES
At this point, some other turoials refer to a Reference Source Path option, this is not available in VS 2010, see this forum post for confirmation. Also, some tutorials refer to a TARGET GAME path, this is not available either with this build.
Under GENERAL | SCRIPT COMPILER | UCC PATH use the select path button to select: \Binaries\Win32\UDK.exe
Under GENERAL | SCRIPT COMPILER | BASE CONTENT PATH and GAME CONTENT PATH, the default values should be ok (another reason why we moved the the VS project files up one folder level). If these options are RED, then VS cant find the folder specified. To fix this click on the Select Path Button and select \UDKGame\Content for the GAMECONTENT PATH option and \Engine\Content for the BASE CONTENT PATH.
Under DEBUG | START ACTION | START GAME EXECUTABLE set the path to \Binaries\Win32\UDK.exe
Check ENABLE UNPUBLISHED MODS
- Save the Project
Add The UnrealScript
Right click on the project name My_Game in the Solution Explorer and select t ADD | NEW FOLDER called UDKGame, then create a subfolder in UDKGame called Config. This is to hold the contents of the \UDKGame\Config folder within the UDK installation. Using the same folder structure in Visual Studio just helps keep the workspace oraganised in a similar fashion to the UDK installation folder.
In the Solution Explorer right click on the \UDKGame\Config folder and select ADD | ADD EXISTING ITEM. Navigate to \UDKGame\Config and select all the Default*.ini files. Then click the arrow to the right of Add and select “Add as a link”. This will create a link to the files and prevent them from being copied into the Visual Studio project directory.
- Finally, close the solution (you MUST exit Visual Studio) and then reopen it.
Build the project
Use the Unreal FrontEnd application to compile the project by clicking the SCRIPT button then FULL RECOMPILE. You should recieve a SUCCESS message in green text.
Add your own code
This involves creating new classes (.uc files) and placing them in a particular folder structure inside \Development\Src\. The code we will add will be for a game called ‘My_Game’ The folder structure and file we need to create is underlined below:
There are several ways of creating this file. It is possible to just use Windows Explorer and Notepad to create the new folders and the .uc file. However, the following steps will show you how to use UnCodeX and Visual Studio together so that you can become familiar with these tools.
The basic idea is to use the CREATE NEW CLASS feature within UnCodeX to create the folders and .uc class file automatically from the correct parent class. Then insert a reference to them in visual Studio, and use that as the editing environment.
Using UnCodeX and Visual Studio together
Open UnCodeX and in the class tree, navigate to ENGINE|ACTOR | INFO | GAMEINFO | FRAMEWORKGAME | SIMPLEGAME | UDKGAME | UTGAME. Be aware that this class has changed its location in previous versions of UDK, so you may have to use the search tool to find the UTGAME class, depending on which version of UDK you are using. Right click on UTGAME and select CREATE SUBCLASS
In PACKAGE, enter My_Game
Do not change the parent class, as we need to inherit the features of the UTGAME class
In NEW CLASS, enter My_Game_Info
Ensure CREATE NEW PACKAGE is selected
Select \Development\Src as the base directoty
The new file will open in your default editor for .uc files, which will be Visual Studio.
Close this editor window
- Open DefaultEngineUDK.ini in Visual Studio (look at the project folder on the Solution Explorer pane and expand UDKGame\Config) and in the and search for the [UnrealEd.EditorEngine] section and then add the following line to the bottom of that section
The format of the above line is ModEditPackages=<name of the project>“
Open DefaultGame.ini in Visual Studio and find the following line to the [Engine.Gameinfo] section (In previous versions this line would be found in DefaultEngine.ini so be prepared for it to change in the future !!!)
DefaultGame = UDKBase.SimpleGame
Change this line to:
DefaultGame = My_Game.My_Game_Info
Now switch to Unreal FrontEnd and compile the code in the same way you did earlier.
The compiled version of My_Game_Info can be found at \UDKGame\Scripts\My_Game_Info.u
You may not find the .u file in \UDKGame\Scripts until you have some code in the .uc which actuall does something !
FINALLY – Compile game from within Visual Studio
Now go back to Visual Studio and right click on the project name My_Game in the Solution Explorer and click PROPERTIES
- In DEBUG | START ACTION | LOAD MAP AT STARTUP, set this to the name of your map (if you have one)
- in DEBUG | START ACTION | START WITH SPECIFIED GAME TYPE, enter My_Game.My_Game_Info
Now if you select BUILD | BUILD SOLUTION your game code will compile from within Visual Studio and you can view any compile erros from there.
At this point you have your own UnrealScript project setup, ready to add your own custom code. You can now move onto the Phidget tutorial here.