Tuesday, October 11, 2011

Creating the first class in UnrealScript

To begin creating new UnrealScript classes is necessary to go in the installation folder of the UDK, enter the folder "Development\Src" and create a new folder (e.g., MyScripts). Inside this folder create a new folder "Classes". In the folder "Classes" create a new plain text file and save it with the name "TestLight.uc". In this file write the following:

class TestLight extends PointLight;

var () string Message;

Now we need to include our new folder in the UDK. To do this go to the folder "UDKGame\Config" and open file "DefaultEngine.ini". Look for lines that begin with "+EditPackages=". After the last put the following line:
 
+EditPackages=MyScripts

After that start the editor of the UDK. A message appears saying that the scripts are outdated, click "yes" to compile the scripts. Open the Actor Classes browser by selecting "View->Browser Contents->Actor Classes".
 
To reach our class "TestLight" you must expand the class "Light" and then "PointLight" as shown below.


Click on the class "TestLight" and then right-click in the editing area of the UDK. Choose "Add TestLight Here" and then press F4 to display the Properties window. Click the category with the name TestLight to show the editable attribute "Message" that we created with UnrealScript.