Real information about Unreal Engine 3

Tuesday, June 12, 2012

UnrealScript Beginner's Guide

UnrealScript is the script language provided by Unreal Engine. It allows you to move your characters and cameras, play animation and special effects, even draw HUD. A UDK user only need a text editor to code in UnrealScript. When you start UDK, it will check if UnrealScript code has been modified. When you finish coding and want to test it, you can just restart UDK to recompile UnrealScript. This note will show you how to code with this simple approach.

Writing Scripts


Once you finish installing UDK, you can find UnrealScript files in the "Development\Src\UTGame\Classes" folder. Open "UTCheatManager.uc" with your text editor, and insert the following code snippet into the end of the file:
exec function SetGroundSpeed(float NewSpeed)
{
    Pawn.GroundSpeed = NewSpeed;
}
"UTCheatManager.uc" is a placeholder for cheat commands. It is also a good place to put your test code. The code snippet is a console command, you can use it to set walking speed in the console.

Compiling Scripts


Save the script file and restart UDK. It will detect the script is modified, and ask if it should be recompiled. Click the Yes button, and then it will start to compile scripts in a console window. When it finishes, restart UDK Editor again. If all scripts are not modified after last compilation, this time the editor will show up.

Testing Scripts


Load a map for test. Before you test the command, you have to set the game type in UDK editor. In menu bar, click View > World Properties to open a window like the following picture:
Open "Game Type" category, and then change "Default Game Type" to UTGame. This is because UTGame uses UTCheatManager but the default game type does not.

After these steps, you can start testing the command. There is a green arrow button in the tool bar, push it to start playing the game in the editor.

You can press Tab to open the console bar. Type in the following command and press Enter to execute it:
SetGroundSpeed 1000
Try to walk around, you should find your character move faster. Try different speeds. Hope this gives you a taste of coding in UnrealScript.

0 comments :

Post a Comment

Followers

AD (728x90)

Powered by Blogger.