Learning UnrealScript Part 2 – The UDK Directory

Object-Oriented Programming Languages revolve around the idea of class trees. The best way to understand this is to look at an actual example: there’s a class called Weapon.uc in UDK, and GameWeapon.uc extends off of it. Then UTWeapon.uc extends off of that, and UTWeap_ShockRifle.uc extends off of UTWeapon. Each added “layer” of code adds extra functionality: while Weapon.uc cannot truly function as a weapon, GameWeapon.uc can actually be used in a game. But only UTWeapon.uc can be truly used in Unreal Tournament, and only UTWeap_ShockRifle.uc is able to control the Shock Rifle.

You can think of Weapon.uc as the “trunk” of the class tree, and each added layer as thinner and thinner branches. There are hundreds of UnrealScript files provided with UDK, but they are all organized as part of such a tree. As a programmer, you will need to learn how UnrealScript files build off of each other and how they interact; otherwise, programming will be very difficult.

At this point you may be wondering, “Wow…so many files, so many assets…how am I ever going to keep track of them all?” Thankfully, UDK treats everything, including assets such as models and music tracks, as objects. When coding, you reference these objects using the “.” operator. For example, suppose you had a file called “Awesome_Music” in the package “My_Awesome_Assets”. To reference this in UnrealScript, all you’d have to do is:


Notice how the “.” comes into play. It’s package, then “.”, then the file. Suppose you had a subfolder called “Great_Music_Tracks” inside of “My_Awesome_Assets”. Then the reference would become:


So, the “.” operator is a kind of link from more general “collections” of objects to smaller groups of objects, and finally to the actual object you want to reference.

How does this work with code? Remember than UDK thinks of everything in terms of packages — when you compile UnrealScript by running it through UDK FrontEnd, the code turns into a bunch of .u files that reside in UDKGame –> Scripts, and these files are pretty much the same as .upk. So, to reference “MyAmazingWeapon.uc” which lives in the directory “Development\Src\MyGame\Classes\”, you would do:


Once again, the “.” operator serves as a link: first the package, then the actual file. You need not worry about extending the directory reference any further than that; as long as you provide the package name, UDK should be able to find it AND your file.

What does this have to do with UnrealScript? Well, when I was first starting out as a UDK programmer, one of the biggest problems I had was where exactly to put files. A lot of the errors I made (and a lot of the errors I now see from YouTubers asking for help) stem from this misunderstanding of the UDK directory.

Basically, all your code should live in “Development\Src\”. Within this folder, for each new game you make create a new folder with the same name as your game, and inside that folder make another folder called “Classes”. So, all your custom UnrealScript code will live in the path “Development\Src\[Your game name here]\Classes”. There’ll be many times (whether cross-referencing across classes or in config/localization files) where you’ll need to know the [Game name].[Class] format, so make sure to keep it handy.

Likewise, your game assets live in UDKGame in several folders. Most assets like weapons, music, etc. are in the Content folder (when you put an asset in this folder, also make sure to store it in the respective subfolder, such as Weapons or Audio). Flash assets, though, have their own folder directly under the Content folder. Intro movies played at the start of the game go into the Movies folder, and your custom splash screen goes into Splash. Notice the other folders: Config (all the configuration settings for your game), Localization (text for different languages your game may be made for), and Script (all the code for your game). You will go into these more often as you progress with programming.

Lastly, I’ll go over UDK Frontend. You’ll need to use this program when you finally finish your game, since it’s the one that actually cooks your game and gets it ready for distribution. However, I use it at least 20 times a day for script recompiling. Whenever you make changes to your code, you should recompile them to make sure the changes are free of errors (and, if they are error-free, that they are saved). Just open UDK Frontend, hit the Script button — an orange arrow pointing down to “UC” — and hit “Compile Scripts”. It’s as simple as that.

Next up, we’ll finally get into some basic coding by extending the UTBot class and adding some functions of our own. Along the way, I’ll explain the basic format of an UnrealScript class.

Previous: What is UnrealScript?
Next: Your First Class


7 thoughts on “Learning UnrealScript Part 2 – The UDK Directory

  1. Pingback: Learning UnrealScript Part 1 – What is UnrealScript? | WillyG Productions

  2. Pingback: Learning UnrealScript – Introduction | WillyG Productions

  3. Hey I love your tutorials! Thanks so much for makin them!

    Do you have a set schedual for when they come out? Like monday or tuesday or something?

  4. Pingback: Learning UnrealScript Part 3 – Your First Class | WillyG Productions

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s