Scripting Crash Course

Page last edited 3,713 days ago
From Artisan
Jump to navigation Jump to search

IDE[edit | edit source]

I've been using Unreal X Editor, but I recommend finding another one: nFringe (must have MS Visual Studio installed) or WOTgreal.


Note that if you download Unreal X Editor, you have to point it to your existing UDK installation or it won't compile anything. After you do that, though, clicking 'compile' will execute a commandlet that makes all of the game files for you. Also, don't try to compile any scripts while the UDK Editor is open because it will always throw errors.


Finally, here's the command to compile/build all your files from the command line if you so desire:

<UDK directory>\Binaries\Win32\udk.com make

Note that it is NOT udk.EXE, but udk.COM.

Class Hierarchy/Creating Classes[edit | edit source]

In UDK, there is a specific layout for your classes that must be followed in order for your game to run properly. Place all of your Unreal Scripts for a given package (.uc) inside of the

<UDK directory>\Development\Src\<package name>\Classes 

folder.

Also, note that your class name and the file name must be exactly the same.

Registering Your Packages with UDK[edit | edit source]

In order to register your packages with UDK (so they can be used in the UDK Editor), you need to edit the UDKEngine.ini file located inside of <UDK directory>\UDKGame\Config\.

Open the UDKEngine.ini file, find the section marked "[UnrealEd.EditorEngine]", scroll to the bottom, and insert the line

ModEditPackages=<package name>

underneath the other text there. UDK will now pick up your class files and they can be used inside of UDK (they will be listed under the 'uncategorized' classes in the content browser).

The GameInfo and Mutator Classes[edit | edit source]

GameInfo Class[edit | edit source]

The GameInfo class controls the parameters of the game that you create inside UDK. Here is an example GameInfo class that assigns the class used for each (human) player controller:

class ItemCreationGame extends GameInfo;

defaultproperties
{
    PlayerControllerClass=class'ItemCreationPlayerController'
}


Checking out the GameInfo class itself is instructive--I recommend taking a look at it to see what kinds of variables and functions are in it.

Mutator Class[edit | edit source]

I'm not sure exactly what the differences are between the GameInfo and Mutator classes, but the Mutator class can also be used to modify UDK's default game type.

Running Your Custom Game[edit | edit source]

Navigate to <UDK directory>/Binaries/Win32 and type the following command:

udk <mapname>?<your package>.<extended GameInfo class name>

So, for example, I created a package called "ItemCreation" with a class called "ItemCreationGame" that extends the GameInfo class. Furthermore, I am just loading the example map that comes with UDK. My command will be this:

udk ExampleMap?game=ItemCreation.ItemCreationGame

The game will now run based on your ItemCreationGame class.

Miscellaneous[edit | edit source]

An intro to UDK scripting can be found here: [1] Check out the bottom of that page for more scripting tutorials.