| Home Page | Recent Changes | Preferences

# Default Properties

This is a special part of the UnrealScript Class syntax. It's block of script at the end of a class that declares default values for class properties. This block cannot contain any executable code. Generally the defaultproperties block of a class follows the rules for T3D files.

Default properties are inherited by subclasses, and may in fact be overridden several times as you go down the class tree. The most "recent" (lowest subclass that has a setting for it in it's default properties) takes precedence in this case. This also goes for parts of a struct or array, e.g. you can change the red value of a color property and the green, blue and alpha values are inherited from the super class.

## Example

This shows how to set defaults for arrays (both static and dynamic ones), floats, ints, booleans, strings, structs (MyColor), enums (RemoteRole), objects (MyProjectileClass; sounds, textures, fonts, meshes or subobjects are handled likewise) and names (MyDamageType). Note that you can also specify objects only by giving the name, i.e. RocketMk2 instead of class'Botpack.RocketMk2'.

    defaultproperties
    {
         MyFloat=8.000000
         MyInt=5
         MyBoolean=True
         MyString="Hello World!"
         RemoteRole=ROLE_None
         MyDamageType=Jolted
         MyProjectileClass=class'Botpack.RocketMk2'
         MyColor=(R=128,G=20,B=255)
         MyStaticArray1(0)=5
         MyStaticArray1(2)=3
         MyDynArray1=("array","on","a","single","line")
         MyDynArray2(0)="multiple"
         MyDynArray2(1)="lines"
         MyDynArray2(2)="for"
         MyDynArray2(3)="this"
         MyDynArray2(4)="one"
    }

### Notes

- The syntax of the default properties block is pretty strict for an arcane reason. Particularly adding spaces before or after the "=" will lead to errors in pre-UT2003 versions. Also adding spaces inside the parentheses for a struct or single-line dynamic array will not work.
- As stated above, the default properties block is only parsed, but in no way executed. You can't put any executable code in there (or complex expressions or variable references at the right side of an assignment, for that matter). You can use constants to initialize a value in defaultproperties, at least in UT2003.

      const SingleShot = 0x00000001;

      defaultproperties
      {
           FireModes = SingleShot;
      }

- Don't expect block comments to work properly there either, you can comment out the whole block but trying to comment out a line can produce weirdness. The following example will not count as a comment, but will be parsed as if the /* */ wasn't there:

      /*
      defaultproperties
      {
           MyVar=3
      }*/

- While block comments do not work (the default properties parser will miss the start and end due to the nature of the parser), it does in fact respect single-line comments.

      defaultproperties
      {
          // This is a valid comment
          //MyVal=0.1234
      }

- When assigning values to static or dynamic array elements in the defaults block don't use square brackets, it won't work, use ordinary parentheses or you'll get an "unknown property in default block" error when compiling.
- The default properties block will not show up when you are using UnrealEd's build-in Script Editor. You can however right-click the class in the actor browser and select "Default Properties" to check and modify them.
- Any variables that specified as config will have any default values replaced by those specified in the appropriate .ini file, just as placed Actors with modified values will replace those specified in the class.
- Note that newer builds of the engine (i.e. anything newer than UT) support more robust parsing of the defaultproperties, including extra whitespace and semi-colons.
- The compiler that came with UT2003 checks, whether classes specified in the defaults block exist, but it doesn't check whether they are allowed there. In particular this means you can assign class'Commandlet' to a variable of type class<Actor>. The variable will contain the default value None then, but the compiler doesn't complain about it.

## Inheritance

Not readily apparent to some is that your defaultproperties block can become fairly large if you consider how much you've inherited. Consider

Object >> Actor >> Inventory >> Weapon >> CustomWeapon

I've seen a few people who assume that defaultproperties is something special, but it's just a basic constructor for your class so all the variables and settings from every class in your tree are available there as well. In the case of Weapon bJustTeleported (Actor) and bMovable (Actor) are available for your use, even if they don't make much sense by the time you get to them.

## Accessing

    Actor.default.<property>=<DefaultValue>;

## Features in later engine versions

It is possible to create subobjects in the defaultproperties block of a class. This technique is widely used in the UT2003 XInterface package to create GUI controls to be placed on a dialog box.

## Default properties in UnrealEd

The Default properties block is omitted in UnrealEd's [script editor]?. Instead, properties are set in an extra instance of Actor properties window, accessed from the Actor classes browser. Do one of:

- Select the class, [Actor Classes Browser Menu]? → Class → Default Properties...
- Select the class, and click the properties button on the Actor classes browser toolbar
- Right-click the class and select Default Properties... from the context menu.

The downsides of this behaviour are:

- If you paste in a script, you'll have to remove the Default properties block: it won't compile.
- You can't access hidden variables in the default properties window.

To access hidden variables, call up the window with the console command:

     editdefault class=<classname>

## Comments

zStorm: (Fixed) It seems as though UCC under certain circumstances has issues with decompiling the default properties. If for instance you decompile a file that has a struct in the default properties, it may insert spaces into the struct declaration.

What should be ZoneGravity=(X=0.00,Y=0.00,Z=-950.00) becomes ZoneGravity=(X=0.00, Y=0.00, Z=-950.00) which is not allowed.

## Related Topics

- UnrealScript
- Class Syntax
- [Variable Types]?
- Static Function
- Subobject

The Unreal Engine Documentation Site

Wiki Community

Topic Categories

Image Uploads

Random Page

Recent Changes

Offline Wiki

Unreal Engine

Console Commands

Terminology

Mapping Topics

Mapping Lessons

UnrealEd Interface

Questions&Answers

Scripting Topics

Scripting Lessons

Making Mods

Class Tree

Questions&Answers

Modeling Topics

Questions&Answers

Log In