Sniper's Paradise!


Unreal Compiling Tutorial

This tutorial will give you some tips for optimal Unreal coding and how to extract existing and create models for importing into Unreal.

Assumptions

Its assumed that you know how to open a DOS-box and navigate through directories. You should also have UnrealEd up and running before continuing to read this tutorial.

The tutorial

There are two ways of coding and compiling your UScripts. One is using UnrealEd, the other is with a text-editor (the coding part) and ucc (for compiling). Both are covered below.

Using UnrealEd to complie code

This is the easiest way to code if you're new to the world of UScript. Use the "Browser" window on the right of the screen, and set the top listbox to "Classes". Now you will see all the child classes of the Actor class. Those are the ones you'll use most of the time.

You can click the to expand the tree and see even more classes. To view the code of a class, double-click on its name. To create a new child of a class, click on its name, and then click the 'New' button at the bottom of the screen. This will show a box where you can type the name of the new class, and the package it will be stored in.

To compile your newly created code, hit F7. If there is any error, UnrealEd will tell you, and jump to the appropriate line of code. Remember you have to save your packages (the 'Save' button at the bottom of the 'Browser' window) before you can use it! You have to compile and save each time you've changed a class and want to test it out.

UnrealEd has a nice syntax highlighting. Unfortunately, the right colors will show up after you've compiled your code, and not while typing it. Another plus for UnrealEd is the ability to easily browse the classes tree.

UnrealEd also has some negative things. It is really slow, and often interprets a single-click as being a double-click. When working on two classes simultaniously, you often have to scroll the browser window a lot, which will become quite annoying after a while. It is impossible to addtextures, meshes and sound to your package from UnrealEd. Of course, you can use separate texture and sound packages, but your class is much easier to distribute and install if everything is in one file.

Using UCC to compile code

This process may seem longer and tedious but once you get use to it, it's a much nicer way and the prefered method to compile code using a text editor and Ucc make. When importing models you must use UCC MAKE otherwise the modeling will not import.

To prepare your computer for coding and compiling without UnrealEd, you have to export all the .u files to their textual representations. To do this, fire up UnrealEd, and click the "Export All" button in the classes browser. This will create a subdirectory for every package in your Unreal directory, with all the classes in the 'Classes' subdirectory. An example:

The package AssaultSniper contains the following classes:

Exporting this package will create the following files and directories:

Unreal
    +--- AssaultSniper
            +---- Classes
            +----- AssaultnSniperRifle.uc
            +----- AssaultSniperAmmo.uc
            +----- AssaultSniperEffect.uc
            +----- SniperArmor.uc
            +----- SniperBoots.uc
            +----- SniperBelt.uc

The exported files can then be edited by any text editor you prefer. To compile see the compling section below.

Importing Models

Step 1: Creating the model

First create a model making sure that the model collision is set correctly or the model will behave weird (Float or sink in the floor). Make sure that your textures have sizes that are powers of 2 e.g. 64x64, 256x256 or 64x128. Also make sure that the texture is in the .pcx format and has 256 colors. When you finished your model you will have to convert it to a format Unreal understands. In Milkshape choose Export and the choose the UT/Unreal format. Milkshape creates two .3d files, those are the meshes and a .uc file this is the script. If you are using another modelling tool you will probably need 3ds2unr to create those files.

Step 2: Setting up the environment

Now create a new folder in your existing Unreal folder with the name of the package you are creating. In this example we will call the folder "Shapes" because it will be a package that contains various shapes. Inside the shapes folder you will need to create 2 additional folders and name them "Classes" and "Models". Copy the .uc file you created or exported and edited and paste it in the classes folder. Place all your .3d files and textures in the models folder

Now you should have something like this:

Unreal
 +-- Shapes
      +-- Classes
      +-- MODELS

Step 3: Making the code

Now we have to make some changes to the .uc file we exported. This can be done with a normal text editor or with Notepad. In this example we will be making a Unreal Decoration.

Change:

class Flatball expands Actor;
To:
class Flatball expands Decoration;

This is because Decorations can be pushed and by doing it this way we don't have to make extra code.

#exec TEXTURE IMPORT NAME=Jtex1 FILE=texture1.pcx GROUP=Skins FLAGS=2
#exec TEXTURE IMPORT NAME=Jtex1 FILE=texture1.pcx GROUP=Skins PALETTE=Jtex1
#exec MESHMAP SETTEXTURE MESHMAP=Flatball NUM=1 TEXTURE=Jtex1

Change all the "texture1.pcx" occurencies by the name of your texture. In the example this is "Greenstone.pcx". Note that ONLY .pcx files can be used for textures. Jtex1 is the name that your texture gets in the Unreal Editor. If you like you can change all Jtex1 occurencies by something more descriptive.

Now add everything below the line to the defaultproperties section.

defaultproperties
{
    DrawType=DT_Mesh
    Mesh=Flatball

// Drawscale scales the model
// Because the model itself is very small I made it five times as big
    DrawScale=5

// Set the correct CollisionCylinder
// Activate the Radi view in the editor and adjust the properties so
// the collisioncylinder just fits around the model.
// Look at the Vase or Woodenbox decoration for an example.
    CollisionHeight=70.000000
    CollisionRadius=50.000000

// Set these properties to make the model pushable
    bPushable=True
    bStatic=False
    bCollideActors=True
    bCollideWorld=True
    bBlockActors=True
    bBlockPlayers=True

// More Mass is harder to push
    Mass=50.000000
}

Compiling

Now we are going to compile our model. Open up the Unreal.ini file and find the [Editor.EditorEngine] section. Now add "EditPackages=Shapes" to this section and save the Unreal.ini file. If the file already exists you must remove it from your system directory. I.E. Unreal\System\Shapes.u. UCC will only compile packages which are in the "EditPackages" list, and which don't exist.

Open a dos prompt, CD to the System directory of Unreal, and type: ucc make. This will start the compiler and the output should look something like this.

C:\Unreal\System>del shapes.u

C:\Unreal\System>ucc make
--------------------Core--------------------
--------------------Engine--------------------
--------------------Editor--------------------
--------------------UWindow--------------------
--------------------Fire--------------------
--------------------IpDrv--------------------
--------------------UWeb--------------------
--------------------UBrowser--------------------
--------------------UnrealShare--------------------
--------------------UnrealI--------------------
--------------------UMenu--------------------
--------------------IpServer--------------------
--------------------Shapes--------------------
Analyzing...
Parsing Flatball
Mesh LOD processing: Flatball
Compiling Flatball
Success - 0 error(s), 0 warnings

C:\Unreal\System>

C:\Unreal\System>_

If there are any error messages, edit your code and open up the DOS prompt again to recompile your code

If everything is correct the Flatball model will be compiled and a Shapes.u file should have been created in the Unreal/system folder. Start up the editor and load the Shapes package and look in the class viewer under Decoration and there is your model ready to be used. Place the model in a map and activate the Radi-view. Now check if the collisioncylinder has the right size. If it is to big or small change the CollisionHeight and CollisionRadius to make the collisioncylinder the size you want it to have. When you have found the perfect values for the collisioncylinder you should change the CollisionHeight and CollisionRadius porperties in the script to the values you just found. Recompile and there is your model.

Unfortunately, this method doesn't allow you to quickly see which classes are decendants of.

By default the ucc make command examines all of the EditPackages lines searching for packages which have no corresponding .u (a compiled package file) files and attempts to compile them. If you have previously built Shapes and you have updated the code the build command will not recompile your package unless your first delete it.

Sometimes you are forced to use the UCC method. For instance, if you've created a new mesh for a weapon, you HAVE to create the package with UCC, otherwise the mesh won't be included in it!

When you think your package is finished you can remove the entry you made in the Unreal.ini file.

INT Files

One of the things that's really easy to forget is the INT file associated with your new package. This file defines the public classes in the package. Look in any of the INT files for examples of this. Remember to include the [Public] directive at the top of the file though or your mod won't be visible in the Unreal front end. It's worth keeping a copy of your INT file in the/Unreal/YourModPackage directory so you don't lose it and always have an up to date version.

INT files are one of the Unreal Engine's file formats. These files are used by the Unreal engine for reference. Instead of searching all the packages made accessible to it to find the resources it's looking for, it simply reads the lists of resources contained in these files. In addition, they are used for language localization and that's the origin of the file extension .int for "international" as well.

You can create localized versions of this class by writing the corresponding localization files. This will be easier if you use UnrealEd to create the international (English) version of this file first. Open UnrealEd, load your .u file for Example: MyMod and and type "dumpint MyMod" in the UnrealEd Console. UnrealEd created the file MyMod.int for you which contains all localizable variables that have been set in the defaultproperties.



Spam Killer

Back To Top
2005 Sniper's Paradise
All logos and trademarks are properties of their respective owners.
Unreal™ is a registered trademark of Epic Games Inc.
Privacy Policy
Website by Softly
Powered by RUSH