Variables: Difference between revisions

From Unreal Wiki, The Unreal Engine Documentation Site
Ikuto (talk | contribs)
New page: == Important notice to editors == {{stub}} This article is a stub to relation of the fact, that primarily article creator have mainly filled in stuff about Unreal Engine 1 a...
 
rewritten for less redundancy with other pages
Line 1: Line 1:
== Important notice to editors ==
[[wp:Variable#Computer programming|Variables]] are named storage slots for pieces of data. All [[UnrealScript]] variables are [[wp:static typing|staticly-typed]], that means you can only store a specific type of data in them and the type of data is defined in the variable [[wp:declaration (computer science)|declaration]].
{{stub}}
This article is a stub to relation of the fact, that primarily [[User:Ikuto|article creator]] have mainly filled in stuff about Unreal Engine 1 and some aspects of Unreal Engine 2. Any help on expanding this article with Unreal Engine 2 and Unreal Engine 3 stuff will be much appreciated.


__TOC__
There are three basic types of variables in UnrealScript:
* Class variables, which can only be declared at the [[class]] [[wp:Scope (programming)|scope]], before any function, operator, delegate or [[state]] declaration.
* Struct members, which are declared inside their [[struct]]'s declaration block.
* Local variables, which can be declared at the start of [[function]], [[operator]] and [[delegate]] bodies before any code statements. (For readability's sake, this article will imply operators and delegates when it mentions functions, unless otherwise noted.)


== Simple Variables ==
==Declaration==
A simple class or struct member variable declaration looks like this:
'''var''' ''[[#Modifiers|[modifiers]]]'' [[type]] variablename''''';'''
The ''variablename'' can be any combination of the letters A-Z (case-insensitive), the digits 0-9 and the underscore character _ with two restrictions:
* The name may not start with a digit.
* The name must be shorter than 64 characters.
The ''type'' can not only be a type specification, but also a [[struct]] or [[enum]] declaration.


Here are some examples of instance variable declarations in UnrealScript:
You can declare multiple variables of the same type in one declaration:
'''var''' ''[[#Modifiers|[modifiers]]]'' [[type]] variablename1''',''' variablename2''',''' ...''';'''
Each of the variablke names may optionally have an array size specification to create a [[static array]]:
variablename'''['''arraysize''']'''
You can mix static arrays and non-array variables in a single declaration. The array size only applies to the variable you appended it to.


<uscript>var int a; // Declare an integer variable named "A".
To make the variable accessible from within [[UnrealEd]]'s property windows, use the following syntax:
var byte Table[64]; // Declare an array of 64 bytes named "Table".
'''var('''''[groupname]''''')''' ''[[#Modifiers|[modifiers]]]'' [[type]] variablename''';'''
var string[32] PlayerName; // Declare a max 32-character string.
The ''groupname'' must be an identifier if specified. If omitted, the class name is used as group name. For struct members, the group name has no effect.
var actor Other; // Declare a variable referencing an actor.</uscript>


Variables can appear in two kinds of places in UnrealScript: instance variables, which apply to an entire object, appear immediately after the class declarations. Local variables appear within a function, and are only active while that function executes. Instance variables are declared with the "var" keyword. Local variables are declard with the "local" keyword.
Local variable declarations are similar, but a bit simpler:
'''local''' [[type]] variablename''';'''
You can declare static arrays and multiple variables of the same type as described for class and struct variables above. The ''type'' must be an existing type. It is not allowed to declare new structs or enums here.


Here are the basic variable types supported in UnrealScript:
==Modifiers==
For class and struct variables you are allowed to specify one or more variable modifiers. These change the way the variable works in certain situations.
* <sup>S</sup> &ndash; The modifier can be used for struct members.
* <sup>1</sup> &ndash; The modifier is available in [[Unreal Engine 1]].
* <sup>2</sup> &ndash; The modifier is available in [[Unreal Engine 2]].
* <sup>3</sup> &ndash; The modifier is available in [[Unreal Engine 3]].
* (no number) &ndash; The modifier is available in all Unreal Engine generations.


* byte: A single-byte value ranging from 0 to 255.  
===Access modifiers===
* int: A 32-bit integer value.  
The following modifiers only apply to class variables and specify, which other classes are allowed to access the variable. The access rules are enforced by the compiler.
* bool: A boolean value: either "true" or "false".  
; const<sup>S</sup>: Prevents any changes to this variable from within UnrealScript. You are still allowed to specify a value in the [[defaultproperties]] block and access the variable's value in your code. This property is mostly used to protect variables with a special meaning to native code. Classes with '''const''' variables usually have a corresponding setter function for each variable.
* float: A 32-bit floating point number.  
; deprecated<sup>2,3</sup>: Signals that this variable should no longer be used. Accessing deprecated variables will throw a compiler warning. [[Unreal Engine 3]] will load the value of a '''deprecated''' variable, but ignore it during save.
* string: A string of characters.  
; private<sup>S,2,3</sup>: Private variables can only be accessed from within the class they were declared in. Other classes, even subclasses, can't access them.
* name: The name of an item in Unreal (such as the name of a function, state, class, etc). Names are stored as a 16-bit index into the global name table. Names correspond to simple strings of 1-31 characters. Names are not like strings: strings can be modified dynamically, but names can only take on predefined name values.  
; protected<sup>S,2,3</sup>: Access to protected variables is only allowed from within the same class and its subclasses. Sibling classes, parent classes and other, unrelated classes can't "see" protected variables.
; public<sup>S,2,3</sup>: The default access rule. If no other access rule is specified, this is one is implied. Public variables can be accessed from any other class. Usually you will see this modifier in Unreal Engine 3, along with a native code snippet. One of the most common examples is <code>public{private}</code>, which means the variable is declared as public for UnrealScript, but as private for native code.


* Enumeration: A variable that can take on one of several predefined name values. For example, the ELightType enumeration defined in the Actor script describes a dynamic light and takes on a value like LT_None, LT_Pulse, LT_Strobe, and so on.
===Modifiers affecting values===
* Object and actor references: A variable that refers to another object or actor in the world. For example, the Pawn class has an "Enemy" actor reference that specifies which actor the pawn should be trying to attack. Object and actor references are very powerful tools, because they enable you to access the variables and functions of another actor. For example, in the Pawn script, you can write "Enemy.Damage(123)" to call your enemy's Damage function – resulting in the enemy taking damage. Object references may also contain a special value called "None", which is the equivalent of the C "NULL" pointer: it says "this variable doesn't refer to any object".  
These modifiers affect the default value of the variable in some way.


* Structs: Similar to C structures, UnrealScript structs let you create new variable types that contain sub-variables. For example, two commonly-used structs are "vector", which consists of an X, Y, and Z component; and "rotator", which consists of a pitch, yaw, and roll component.
; config<sup>S</sup>: Makes the variable configurable. The default variable value is read from an [[INI file]] when the class is loaded. Each subclass has its own version of the variable value in its INI file section. If the class is declared with the [[PerObjectConfig]] modifier, the initial instance value of the variable is read from a separate INI section for that object instance.
; databinding<sup>3</sup>: The variable can be manipulated by [[Unreal Engine 3]]'s data store system.
; duplicatetransient<sup>3</sup>: Similar to '''transient''' (see below) but applies to object duplication.
; globalconfig<sup>S</sup>: Similar to the '''config''' modifier, but a '''globalconfig''' variable's default value is always read from the INI section of its declaring class, even for subclasses.
; input: Attaches the variable to the input system. This is only meaningful for float and byte variables, which can be tied to axis and button input respectively. Input variables are only filled for the local player actor.
; instanced<sup>3</sup>: Only meaningful for reference variables. Subobjects assigned to instanced variables are duplicated when an instance of the class is created.
; localized<sup>S</sup>: Makes the variable localizable. The default value of the variable is read from a [[localization file]] when the class is loaded. Each subclass can have its own localized versions of the variable value. In [[Unreal Engine 1]] and [[Unreal Engine 2|2]] and if the class is declared as [[PerObjectLocalized]] in [[Unreal Engine 3]], each instance of the class can have its own set of localized variable values. This is useful for actors placed in a map.
; transient<sup>S</sup>: The variables is set to its null value when initializing object instances. The variable's value is never saved to disk in any way.
; travel<sup>1,2</sup>: For single player gametypes where a player advances from one map to the next, carrying over all inventory items. Instance variables marked as '''travel''' will keep their value across the map change. Only has an effect for the PlayerPawn in UE1 (or the PlayerController and its Pawn in UE2) and its Inventory chain.


Variables may also contain additional specifiers such as "const" that further describe the variable. Actually, there are quite a lot of specifiers which you wouldn't expect to see in a general-purpose programming language, mainly as a result of wanting UnrealScript to natively support many game- and environment- specific concepts:
===Modifiers affecting UnrealEd===
These modifiers have some kind of effect in [[UnrealEd]], usually in the actor properties window.


* const: Advanced. Treats the contents of the variable as a constant. In UnrealScript, you can read the value of const variables, but you can't write to them. "Const" is only used for variables which the engine is responsible for updating, and which can't be safely updated from UnrealScript, such as an actor's Location (which can only be set by calling the MoveActor and SetLocation functions).  
; edfindable<sup>S,2</sup>: Adds a 'Find' button to the variable in the property window, which can be used to select an actor from the UnrealEd viewports. For obvious reasons this only makes sense for variables of type Actor or any of its subclasses.
* input: Advanced. Makes the variable accessible to Unreal's input system, so that input (such as button presses and joystick movements) can be directly mapped onto it. Only relevent with variables of type "byte" and "float".  
; editconst<sup>S</sup>: The variable is read-only in the property window.
* transient: Advanced. Declares that the variable is for temporary use, and isn't part of the object's persistent state. Transient variables are not saved to disk. Transient variables are initialized to zero when an actor is loaded.
; editconstarray<sup>S,2</sup>, editfixedsize<sup>S,3</sup>: For dynamic arrays, removes the buttons from the properties window that would change the array length.
* native: Advanced. Declares that the variable is loaded and saved by C++ code, rather than by UnrealScript.
; editinline<sup>S,2,3</sup>: Only meaningful for object variables. Displays the referenced object's properties as a subgroup below the variable in the property window. If the variable has the value None, a drop-down list of allowed classes can be used to create a new object which is assigned to this variable.
* private: The variable is private, and may only be accessed by the class's script; no other classes (including subclasses) may access it.
; editinlineuse<sup>S,2,3</sup>: Same as '''editinline''', but also adds a 'Use' button to the variable to apply the object selected in the relevant browser for this type of object. Note that the 'Use' button is always available in [[Unreal Engine 3]].
* editinline: Advanced. Indicates that object reference \ class reference can be expanded in actor \ object properties <Unreal Engine 2+>
; interp<sup>3</sup>: The variable can be manipulated by [[Unreal Engine 3]]'s [[Matinee]] system. Only really meaningful for float and vector variables.
* editconst: Advanced. Indicates that property can not be modified in the properties window
; noclear<sup>S,3</sup>: Instructs the editor to prevent the user from setting this variable to None. Only really meaningful for object variables.
; noimport<sup>S,3</sup>: The variable's value will not be imported from text representation, i.e. when importing from a [[T3D file]] or pasting from clipboard.
; nontransactional<sup>S,3</sup>: The variable is not affected by UnrealEd's undo/redo features.


Arrays are declared using the following syntax:


<uscript>var int MyArray[20]; // Declares an array of 20 ints.</uscript>
===Other modifiers===
; editinlinenotify<sup>S,2</sup>: Seems to provide special feedback to native code if the variable is edited in a property window. Seems only relevant for native classes and implies '''editinline'''.
; export<sup>S,2,3</sup>: For object properties. Objects assigned to this variable are exported as subobjects when exporting class scripts or when exporting actors to [[T3D file]]s or clipboard.
; init<sup>S,3</sup>: Changes the way string and dynamic array variables are exported to headers for native classes. Default values for this kind of variable are ignored when creating instances of the class.
; native: The variable is loaded and saved in native code. Only valid in native classes.
; noexport<sup>S,2,3</sup>: Prevents the variable's value from being exported when exporting class scripts or when exporting actors to [[T3D file]]s or clipboard.
; repnotify<sup>3</sup>: Can be used on replicated actor variables to instruct the engine to call the [[UE3:Actor events (UT3)#ReplicatedEvent|ReplicatedEvent]] function whenever a value was received for the variable.


UnrealScript supports only single-dimensional arrays, though you can simulate multidimensional arrays by carrying out the row/column math yourself.
==Initial values==
The initial values of class variables can be specified in the [[defaultproperties]] block. The initial value can be different in subclasses without affecting the value of parent classes. Some class variables, for example Name, Outer, Tag or Location, are initialized with other values when an instance of the class is created.


In UnrealScript, you can make an instance variable "editable", so that users can edit the variable's value in UnrealEd. This mechanism is responsible for the entire contents of the "Actor Properties" dialog in UnrealEd: everything you see there is simply an UnrealScript variable, which has been declared editable.
Initial values of struct members can be specified in thee [[structdefaultproperties]]. In structs that extend other structs, the initial value can differ from the value in the parent struct. Since structs are data types and only exist as values of other variables, initial member values for those variables may differ from the default struct member value.


The syntax for declaring an editable variable is as follows:
The initial value of a local variable is always the null value for the declared variable [[type]]. The initial value for function parameters is the value passed in when the function is called. Omitted optional parameters initially contain the type's null value. In [[Unreal Engine 3]] it is also possible to specify a different initial value for omitted optional parameters.


<uscript>var() int MyInteger; // Declare an editable integer in the default category.
==Accessing variables==
var(MyCategory) bool MyBool; // Declare an editable integer in "MyCategory".</uscript>
Class variables can be accessed directly by just specifying their name from instance functions, state code or the [[replication block]] inside the declaring class or any of its subclasses.


== Object and actor reference variables ==
The default value for a class variable can be accessed directly by using the keyword '''default''' and the context operator '.' from anywhere inside the class, including static functions:
'''default.'''variablename
The default value of another class can be accessed by providing a different class context to the '''default''' keyword:
objectreference'''.default.'''variablename
The object reference can be an [[Literals#Objects|object literal]] or an object reference variable. If the type of the object reference is a Class or a [[class limiter]], that class is used, otherwise the referenced object's class type is used to access the default variable value. When using an object literal is usually doesn't make sense to use a non-class literal because you usually know the class of the referenced object and the engine really doesn't care about the actual object if it is only interested in the class anyway.


You can declare a variable that refers to an actor or object like this:
Struct member variables and class variables of other classes or other instances of the same class can be accessed with the context operator '.', like in the following example:
 
<uscript>
<uscript>var actor A; // An actor reference.
function getX(vector V)
var pawn P; // A reference to an actor in the Pawn class.
var texture T; // A reference to a texture object.</uscript>
 
The variable "P" above is a reference to an actor in the Pawn class. Such a variable can refer to any actor that belongs to a subclass of Pawn. For example, P might refer to a Brute, or a Skaarj, or a Manta. It can be any kind of Pawn. However, P can never refer to a Trigger actor (because Trigger is not a subclass of Pawn).
 
One example of where it's handy to have a variable refering to an actor is the Enemy variable in the Pawn class, which refers to the actor which the Pawn is trying to attack.
 
When you have a variable that refers to an actor, you can access that actor's variables, and call its functions. For example:
 
<uscript>// Declare two variables that refer to a pawns.
var pawn P, Q;
 
// Here is a function that makes use of P.
// It displays some information about P.
function MyFunction()
{
{
// Set P's enemy to Q.
  return V.X;
P.Enemy = Q;
}
 
</uscript>
// Tell P to play his running animation.
This accesses the struct member variable ''X'' of the vector value passed to the function as parameter ''V''. The parameter ''V'' is a local variable to the function ''getX''. Local variables can only be accessed inside their containing function.
P.PlayRunning();
}</uscript>
 
Variables that refer to actors always either refer to a valid actor (any actor that actually exists in the level), or they contain the value "None". None is equivalent to the C/C++ "NULL" pointer. However, in UnrealScript, it is safe to access variables and call functions with a "None" reference; the result is always zero.
 
Note that an object or actor reference "points to" another actor or object, it doesn't "contain" an actor or object. The C equivalent of an actor reference is a pointer to an object in the AActor class (in C, you'd say an AActor*). For example, you could have two monsters in the world, Bob and Fred, who are fighting each other. Bob's "Enemy" variable would "point to" Fred, and Fred's "Enemy" variable would "point to" Bob.
 
Unlike C pointers, UnrealScript object references are always safe and infallible. It is impossible for an object reference to refer to an object that doesn't exist or is invalid (other than the special-case "None" value). In UnrealScript, when an actor or object is destroyed, all references to it are automatically set to "None".
 
== Class Reference Variables ==
 
In Unreal, classes are objects just like actors, textures, and sounds are objects.  Class objects belong to the class named "class".  Now, there will often be cases where you'll want to store a reference to a class object, so that you can spawn an actor belonging to that class (without knowing what the class is at compile-time).  For example:
 
<uscript>var() class C;
var actor A;
A = Spawn( C ); // Spawn an actor belonging to some arbitrary class C.</uscript>
 
Now, be sure not to confuse the roles of a class C, and an object O belonging to class C.  To give a really shaky analogy, a class is like a pepper grinder, and an object is like pepper.  You can use the pepper grinder (the class) to create pepper (objects of that class) by turning the crank (calling the Spawn function)...BUT, a pepper grinder (a class) is not pepper (an object belonging to the class), so you '''MUST NOT TRY TO EAT IT!'''
 
When declaring variables that reference class objects, you can optionally use the special class<classlimitor> syntax to limit the variable to only containing references to classes which expand a given superclass.  For example, in the declaration:
 
<uscript>var class<actor> ActorClass;</uscript>
 
The variable ActorClass may only reference a class that expands the "actor" class.  This is useful for improving compile-time type checking.   For example, the Spawn function takes a class as a parameter, but only makes sense when the given class is a subclass of Actor, and the class<classlimitor> syntax causes the compiler to enforce that requirement.
 
As with dynamic object casting, you can dynamically cast classes like this:
 
<uscript>class<actor>( SomeFunctionCall() )</uscript>
 
== Enumerations ==
 
Enumerations exist in UnrealScript as a convenient way to declare variables that can contain "one of" a bunch of keywords. For example, the actor class contains the enumeration EPhysics which describes the physics which Unreal should apply to the actor. This can be set to one of the predefined values like PHYS_None, PHYS_Walking, PHYS_Falling, and so on.
 
Internally, enumerations are stored as byte variables. In designing UnrealScript, enumerations were not seen as a necessity, but it makes code so much easier to read to see that an actor's physics mode is being set to "PHYS_Swimming" than (for example) "3".
 
Here is sample code that declares enumerations.
 
<uscript>// Declare the EColor enumeration, with three values.
enum EColor
{
CO_Red,
CO_Green,
CO_Blue
};
 
// Now, declare two variables of type EColor.
var EColor ShirtColor, HatColor;
 
// Alternatively, you can declare variables and
// enumerations together like this:
var enum EFruit
{
FRUIT_Apple,
FRUIT_Orange,
FRUIT_Bannana
} FirstFruit, SecondFruit;</uscript>
 
In the Unreal source, we always declare enumeration values like LT_Steady, PHYS_Falling, and so on, rather than as simply "Steady" or "Falling". This is just a matter of programming style, and is not a requirement of the language.
 
UnrealScript only recognizes unqualified enum tags (like FRUIT_Apple) in classes where the enumeration was defined, and in its subclasses.  If you need to refer to an enumeration tag defined somewhere else in the class hierarchy, you must "qualify it":
 
<uscript>FRUIT_Apple // If Unreal can't find this enum tag...
EFruit.FRUIT_Apple // Then qualify it like this.</uscript>
 
== Structs ==
 
An UnrealScript struct is a way of cramming a bunch of variables together into a new kind of super-variable called a struct. UnrealScript structs are just like C structs, in that they can contain any simple variables or arrays.
 
You can declare a struct as follows:
<uscript>// A point or direction vector in 3D space.
struct Vector
{
var float X;
var float Y;
var float Z
};</uscript>
 
Once you declare a struct, you are ready to start declaring specific variables of that struct type:
 
<uscript>// Declare a bunch of variables of type Vector.
var Vector Position;
var Vector Destination;</uscript>
 
To access a component of a struct, use code like the following.
 
<uscript>function MyFunction()
{
Local Vector A, B, C;
 
// Add some vectors.
C = A + B;
 
// Add just the x components of the vectors.
C.X = A.X + B.X;
 
// Pass vector C to a function.
SomeFunction( C );
 
// Pass certain vector components to a function.
OtherFunction( A.X, C.Z );
}</uscript>
 
You can do anything with Struct variables that you can do with other variables: you can assign variables to them, you can pass them to functions, and you can access their components.


There are several Structs defined in the Object class which are used throughout Unreal. You should become familiar with their operation, as they are fundamental building blocks of scripts:
Variables accessed as described in this section can be used as an [[wp:lvalue|L-value]], i.e. used on the left side of an assignment operator or as an [[out]] parameter in a function call.


* Vector: A unique 3D point or vector in space, with an X, Y, and Z component.
{{navbox unrealscript}}
* Plane: Defines a unique plane in 3D space. A plane is defined by its X, Y, and Z components (which are assumed to be normalized) plus its W component, which represents the distance of the plane from the origin, along the plane's normal (which is the shortest line from the plane to the origin).
* Rotation: A rotation defining a unique orthogonal coordinate system. A rotation contains Pitch, Yaw, and Roll components.
* Coords: An arbitrary coordinate system in 3D space.
* Color: An RGB color value.
* Region: Defines a unique convex region within a level.

Revision as of 08:53, 1 October 2008

Variables are named storage slots for pieces of data. All UnrealScript variables are staticly-typed, that means you can only store a specific type of data in them and the type of data is defined in the variable declaration.

There are three basic types of variables in UnrealScript:

  • Class variables, which can only be declared at the class scope, before any function, operator, delegate or state declaration.
  • Struct members, which are declared inside their struct's declaration block.
  • Local variables, which can be declared at the start of function, operator and delegate bodies before any code statements. (For readability's sake, this article will imply operators and delegates when it mentions functions, unless otherwise noted.)

Declaration

A simple class or struct member variable declaration looks like this:

var [modifiers] type variablename;

The variablename can be any combination of the letters A-Z (case-insensitive), the digits 0-9 and the underscore character _ with two restrictions:

  • The name may not start with a digit.
  • The name must be shorter than 64 characters.

The type can not only be a type specification, but also a struct or enum declaration.

You can declare multiple variables of the same type in one declaration:

var [modifiers] type variablename1, variablename2, ...;

Each of the variablke names may optionally have an array size specification to create a static array:

variablename[arraysize]

You can mix static arrays and non-array variables in a single declaration. The array size only applies to the variable you appended it to.

To make the variable accessible from within UnrealEd's property windows, use the following syntax:

var([groupname]) [modifiers] type variablename;

The groupname must be an identifier if specified. If omitted, the class name is used as group name. For struct members, the group name has no effect.

Local variable declarations are similar, but a bit simpler:

local type variablename;

You can declare static arrays and multiple variables of the same type as described for class and struct variables above. The type must be an existing type. It is not allowed to declare new structs or enums here.

Modifiers

For class and struct variables you are allowed to specify one or more variable modifiers. These change the way the variable works in certain situations.

  • S – The modifier can be used for struct members.
  • 1 – The modifier is available in Unreal Engine 1.
  • 2 – The modifier is available in Unreal Engine 2.
  • 3 – The modifier is available in Unreal Engine 3.
  • (no number) – The modifier is available in all Unreal Engine generations.

Access modifiers

The following modifiers only apply to class variables and specify, which other classes are allowed to access the variable. The access rules are enforced by the compiler.

constS
Prevents any changes to this variable from within UnrealScript. You are still allowed to specify a value in the defaultproperties block and access the variable's value in your code. This property is mostly used to protect variables with a special meaning to native code. Classes with const variables usually have a corresponding setter function for each variable.
deprecated2,3
Signals that this variable should no longer be used. Accessing deprecated variables will throw a compiler warning. Unreal Engine 3 will load the value of a deprecated variable, but ignore it during save.
privateS,2,3
Private variables can only be accessed from within the class they were declared in. Other classes, even subclasses, can't access them.
protectedS,2,3
Access to protected variables is only allowed from within the same class and its subclasses. Sibling classes, parent classes and other, unrelated classes can't "see" protected variables.
publicS,2,3
The default access rule. If no other access rule is specified, this is one is implied. Public variables can be accessed from any other class. Usually you will see this modifier in Unreal Engine 3, along with a native code snippet. One of the most common examples is public{private}, which means the variable is declared as public for UnrealScript, but as private for native code.

Modifiers affecting values

These modifiers affect the default value of the variable in some way.

configS
Makes the variable configurable. The default variable value is read from an INI file when the class is loaded. Each subclass has its own version of the variable value in its INI file section. If the class is declared with the PerObjectConfig modifier, the initial instance value of the variable is read from a separate INI section for that object instance.
databinding3
The variable can be manipulated by Unreal Engine 3's data store system.
duplicatetransient3
Similar to transient (see below) but applies to object duplication.
globalconfigS
Similar to the config modifier, but a globalconfig variable's default value is always read from the INI section of its declaring class, even for subclasses.
input
Attaches the variable to the input system. This is only meaningful for float and byte variables, which can be tied to axis and button input respectively. Input variables are only filled for the local player actor.
instanced3
Only meaningful for reference variables. Subobjects assigned to instanced variables are duplicated when an instance of the class is created.
localizedS
Makes the variable localizable. The default value of the variable is read from a localization file when the class is loaded. Each subclass can have its own localized versions of the variable value. In Unreal Engine 1 and 2 and if the class is declared as PerObjectLocalized in Unreal Engine 3, each instance of the class can have its own set of localized variable values. This is useful for actors placed in a map.
transientS
The variables is set to its null value when initializing object instances. The variable's value is never saved to disk in any way.
travel1,2
For single player gametypes where a player advances from one map to the next, carrying over all inventory items. Instance variables marked as travel will keep their value across the map change. Only has an effect for the PlayerPawn in UE1 (or the PlayerController and its Pawn in UE2) and its Inventory chain.

Modifiers affecting UnrealEd

These modifiers have some kind of effect in UnrealEd, usually in the actor properties window.

edfindableS,2
Adds a 'Find' button to the variable in the property window, which can be used to select an actor from the UnrealEd viewports. For obvious reasons this only makes sense for variables of type Actor or any of its subclasses.
editconstS
The variable is read-only in the property window.
editconstarrayS,2, editfixedsizeS,3
For dynamic arrays, removes the buttons from the properties window that would change the array length.
editinlineS,2,3
Only meaningful for object variables. Displays the referenced object's properties as a subgroup below the variable in the property window. If the variable has the value None, a drop-down list of allowed classes can be used to create a new object which is assigned to this variable.
editinlineuseS,2,3
Same as editinline, but also adds a 'Use' button to the variable to apply the object selected in the relevant browser for this type of object. Note that the 'Use' button is always available in Unreal Engine 3.
interp3
The variable can be manipulated by Unreal Engine 3's Matinee system. Only really meaningful for float and vector variables.
noclearS,3
Instructs the editor to prevent the user from setting this variable to None. Only really meaningful for object variables.
noimportS,3
The variable's value will not be imported from text representation, i.e. when importing from a T3D file or pasting from clipboard.
nontransactionalS,3
The variable is not affected by UnrealEd's undo/redo features.


Other modifiers

editinlinenotifyS,2
Seems to provide special feedback to native code if the variable is edited in a property window. Seems only relevant for native classes and implies editinline.
exportS,2,3
For object properties. Objects assigned to this variable are exported as subobjects when exporting class scripts or when exporting actors to T3D files or clipboard.
initS,3
Changes the way string and dynamic array variables are exported to headers for native classes. Default values for this kind of variable are ignored when creating instances of the class.
native
The variable is loaded and saved in native code. Only valid in native classes.
noexportS,2,3
Prevents the variable's value from being exported when exporting class scripts or when exporting actors to T3D files or clipboard.
repnotify3
Can be used on replicated actor variables to instruct the engine to call the ReplicatedEvent function whenever a value was received for the variable.

Initial values

The initial values of class variables can be specified in the defaultproperties block. The initial value can be different in subclasses without affecting the value of parent classes. Some class variables, for example Name, Outer, Tag or Location, are initialized with other values when an instance of the class is created.

Initial values of struct members can be specified in thee structdefaultproperties. In structs that extend other structs, the initial value can differ from the value in the parent struct. Since structs are data types and only exist as values of other variables, initial member values for those variables may differ from the default struct member value.

The initial value of a local variable is always the null value for the declared variable type. The initial value for function parameters is the value passed in when the function is called. Omitted optional parameters initially contain the type's null value. In Unreal Engine 3 it is also possible to specify a different initial value for omitted optional parameters.

Accessing variables

Class variables can be accessed directly by just specifying their name from instance functions, state code or the replication block inside the declaring class or any of its subclasses.

The default value for a class variable can be accessed directly by using the keyword default and the context operator '.' from anywhere inside the class, including static functions:

default.variablename

The default value of another class can be accessed by providing a different class context to the default keyword:

objectreference.default.variablename

The object reference can be an object literal or an object reference variable. If the type of the object reference is a Class or a class limiter, that class is used, otherwise the referenced object's class type is used to access the default variable value. When using an object literal is usually doesn't make sense to use a non-class literal because you usually know the class of the referenced object and the engine really doesn't care about the actual object if it is only interested in the class anyway.

Struct member variables and class variables of other classes or other instances of the same class can be accessed with the context operator '.', like in the following example: <uscript> function getX(vector V) {

 return V.X;

} </uscript> This accesses the struct member variable X of the vector value passed to the function as parameter V. The parameter V is a local variable to the function getX. Local variables can only be accessed inside their containing function.

Variables accessed as described in this section can be used as an L-value, i.e. used on the left side of an assignment operator or as an out parameter in a function call.