I love the smell of UnrealEd crashing in the morning. – tarquin
UE3:Object operators (UT3)
Object (operators) |
Contents
- 1 Bool operators
- 2 Byte operators
- 3 Int operators
- 3.1 ++int
- 3.2 -int
- 3.3 --int
- 3.4 ~int
- 3.5 int++
- 3.6 int--
- 3.7 int * int
- 3.8 int / int
- 3.9 int + int
- 3.10 int - int
- 3.11 int << int
- 3.12 int >> int
- 3.13 int >>> int
- 3.14 int < int
- 3.15 int <= int
- 3.16 int == int
- 3.17 int > int
- 3.18 int >= int
- 3.19 int != int
- 3.20 int & int
- 3.21 int ^ int
- 3.22 int | int
- 3.23 int *= float
- 3.24 int += int
- 3.25 int -= int
- 3.26 int /= float
- 4 Float operators
- 4.1 -float
- 4.2 float ** float
- 4.3 float * float
- 4.4 float / float
- 4.5 float % float
- 4.6 float + float
- 4.7 float - float
- 4.8 float < float
- 4.9 float <= float
- 4.10 float == float
- 4.11 float > float
- 4.12 float >= float
- 4.13 float ~= float
- 4.14 float != float
- 4.15 float *= float
- 4.16 float += float
- 4.17 float -= float
- 4.18 float /= float
- 5 Vector operators
- 5.1 -vector
- 5.2 float * vector
- 5.3 vector * float
- 5.4 vector * vector
- 5.5 vector / float
- 5.6 vector Cross vector
- 5.7 vector Dot vector
- 5.8 vector + vector
- 5.9 vector - vector
- 5.10 vector << rotator
- 5.11 vector >> rotator
- 5.12 vector == vector
- 5.13 vector != vector
- 5.14 vector *= float
- 5.15 vector *= vector
- 5.16 vector += vector
- 5.17 vector -= vector
- 5.18 vector /= float
- 6 Rotator operators
- 7 Quat operators
- 8 Color operators
- 9 String operators
- 10 Name operators
- 11 Object operators
- Object operators in other games:
- RTNP, U1, UT, U2, U2XMP, UE2Runtime, UT2003, UT2004, UDK
- Other member categories for this class:
- static native functions, structs
Operators below are grouped by type and sorted by precedence.
Apart from the operators listed here, there are also a few implicitly declared operators, like assignment, generic struct (in)equality or the conditional operator.
Bool operators
!bool
Logical negation. Returns False if the parameter is True and vice versa.
bool == bool
Equality. Returns True if both parameters have the same value, otherwise False.
bool != bool
Inequality. Returns True if the parameters have different values, otherwise False
bool && bool
Logical AND. Returns True if both parameters are True, otherwise False.
This operator "short-circuits" if the first operand evaluates to False, i.e. in that case the second operand is not evaluated at all because the result is already known.
bool ^^ bool
Logical XOR. This is basically the same as the != operator, except that the inequality operator binds more tightly than XOR.
bool || bool
Logical OR. Returns True if any parameter is True, and False only if both parameters are False.
This operator "short-circuits" if the first operand evaluates to True, i.e. in that case the second operand is not evaluated at all because the result is already known.
Byte operators
++byte
Preincrement operator. The value of A is incremented by one and the result is returned.
--byte
Predecrement operator. The value of A is decremented by one and the result is returned.
byte++
Postincrement operator. The value of A is temporarily stored, then A is incremented by one and the original value is returned.
byte--
Postdecrement operator. The value of A is temporarily stored, then A is decremented by one and the original value is returned.
byte *= byte
Combined multiplication and assign for byte values. Multiplies A with B, stores the result in A and returns it.
byte *= float
Combined multiplication and assign. Multiplies A with B, stores the result in A and returns it. Performs floating point multiplication and typecasts the result to byte.
byte += byte
Combined add and assign. Adds A and B, stores the result in A and returns it.
byte -= byte
Combined subtract and assign. Subtracts B from A, stores the result in A and returns it.
byte /= byte
Combined divide and assign. Divides A by B, stores the result in A and returns it. Note that float values are automatically typecasted to byte for this operator:
local byte b; b = 10; b /= 2.5; // afterwards b is 5, not 4
If you need a floating point operation, use A *= 1.0 / B;
instead.
Int operators
++int
Preincrement operator. The value of A is incremented by one and the result is returned.
-int
Arithmetic negation. The result is a number with the same magnitude, but opposite sign. For zero A the result obviously is 0. Note that this operator maps the smallest possible int number (-2147483648 or 0x80000000) onto itself because its positive counterpart is larger than the largest possible int number.
--int
Predecrement operator. The value of A is decremented by one and the result is returned.
~int
Bitwise NOT, or complement operator. Inverts all bits in the binary representation of A and returns that value.
int++
Postincrement operator. The value of A is temporarily stored, then A is incremented by one and the original value is returned.
int--
Postdecrement operator. The value of A is temporarily stored, then A is decremented by one and the original value is returned.
int * int
Integer multiplication. Multiplies A and B and returns the result.
int / int
Integer division. Divides A by B and returns the result. Any remainder after division is lost. Division by 0 is defined to return 0.
int + int
Integer addition. Adds A and B and returns the result.
int - int
Integer subtraction. Subtracts B from A and returns the result.
int << int
Arithmetic or logical left shift. Moves the bits in the binary representation of A to the left. Higher bits are "pushed out" to the left and from the right, zero bits are "pushed in". Arithmetic left shift corresponds to integer multiplication with 2B.
B is the distance to shift the bits. If it is negative or greater than 31, B is implicitly normalized to the range 0 to 31 as if by B & 0x1F
.
int >> int
Arithmetic right shift. Moves the bits in the binary representation of A to the right. Lower bits are "pushed out" to the right and depending on the sign of the value, either 0 (for positive numbers) or 1 (for negative numbers) bits are "pushed in" from the left. Arithmetic right shift corresponds to integer division by 2B.
B is the distance to shift the bits. If it is negative or greater than 31, B is implicitly normalized to the range 0 to 31 as if by B & 0x1F
.
int >>> int
Logical right shift. Moves the bits in the binary representation of A to the right. Higher bits are "pushed out" to the left and from the right, zero bits are "pushed in".
B is the distance to shift the bits. If it is negative or greater than 31, B is implicitly normalized to the range 0 to 31 as if by B & 0x1F
.
int < int
Less-than comparison operator. Returns True if the value of A is less than the value of B.
int <= int
Less-or-equal comparison operator. Returns True if the value of A is less than or equal to the value of B.
int == int
Equality operator. Returns True if the value of A is equal to the value of B.
int > int
Greater-than comparison operator. Returns True if the value of A is greater than the value of B.
int >= int
Greater-or-equal comparison operator. Returns True if the value of A is greater than or equal to the value of B.
int != int
Inequality operator. Returns True if the value of A differs from the value of B.
int & int
Bitwise AND operator. Performs logical AND on each corresponding pair of bits from A and B and returns the result. Unlike the bool && bool operator, the bitwise AND operator always evaluates both operands.
int ^ int
Bitwise XOR operator. Performs logical XOR on each corresponding pair of bits from A and B and returns the result.
int | int
Bitwise OR operator. Performs logical OR on each corresponding pair of bits from A and B and returns the result. Unlike the logical OR operator, the bitwise OR operator always evaluates both operands.
int *= float
Combined multiply and assign. Multiplies A and B, stores the result in A and returns it.
Note: This operator always performs floating point multiplication and thus may be inaccurate for large values. If you need precision for large values, use A = A * B
instead.
int += int
Combined add and assign. Adds A and B, stores the result in A and returns it.
int -= int
Combined subtract and assign. Subtracts B from A, stores the result in A and returns it.
int /= float
Combined divide and assign. Divides A by B, stores the result in A and returns it.
Note: This operator always performs floating point division and thus may be inaccurate for large values. If you need precision for large values, use A = A / B
instead.
Float operators
Some floating point operators have the potential of overflowing the valid range of float values. If this happens, they return a "float error value". Such a value also propagates through operators and function calls if it is passed as a parameter.
-float
Arithmetic negation. The result is a number with the same magnitude, but opposite sign. For zero A the result obviously is 0.
float ** float
Exponentiation operator. Raises A to the power of B and returns the result. Attempting to raise a negative number to a fractional power results in NaN.
float * float
Floating point multiplication. Multiplies A and B and returns the result.
float / float
Floating point division. Divides A by B and returns the result. Division by zero results in NaN.
float % float
Remainder after (truncated) division, also called the modulo operator. Divides A by B and returns the remainder. Division by zero results in NaN. For negative values of A, the result is negative as well.
float + float
Floating point addition. Adds A and B and returns the result.
float - float
Floating point subtraction. Subtracts B from A and returns the result.
float < float
Less-than comparison operator. Returns True if the value of A is less than the value of B.
float <= float
Less-or-equal comparison operator. Returns True if the value of A is less than or equal to the value of B.
float == float
Equality comparison operator. Returns True if the value of A is equal to the value of B.
float > float
Greater-than comparison operator. Returns True if the value of A is greater than to the value of B.
float >= float
Greater-or-equal comparison operator. Returns True if the value of A is greater than or equal to the value of B.
float ~= float
Approximately-equal comparison operator. Returns True if the values of A and B differ by less than 0.0001.
float != float
Inequality comparison operator. Returns True if the value of A is different from the value of B.
float *= float
Combined multiply and assign. Multiplies A and B, stores the result in A and returns it.
float += float
Combined add and assign. Adds A and B, stores the result in A and returns it.
float -= float
Combined subtract and assign. Subtracts B from A, stores the result in A and returns it.
float /= float
Combined divide and assign. Divides A by B, stores the result in A and returns it.
Vector operators
-vector
Inverts the vector by negating its components. The resulting vector has the same length, but points in the opposite direction.
float * vector
Multiplies the vector's components by a scalar value. The resulting vector's length it the original vector's length multiplied by the absolute value of the scalar. Its direction is the same if the scalar is positive and inversed if the scalar is negative.
vector * float
Same as float * vector, just with swapped operands.
vector * vector
Multiplies the corresponding components of the two vectors and returns them as the corresponding commponents of the resulting vector.
vector / float
Divides the vector's components by a scalar value. The resulting vector's length it the original vector's length divided by the absolute value of the scalar. Its direction is the same if the scalar is positive and inversed if the scalar is negative.
vector Cross vector
Calculates the cross product of the two vectors. The result is a vector perpenticular to both input vectors. Its length is equal to the area of the parallelogram described by the two vectors.
vector Dot vector
Calculates the dot product of the two vectors. The result is a scalar value, the sum of the products of corresponding components of the two vectors.
vector + vector
Adds the two vectors' corresponding components. The resulting vector can be constructed geometrically by attaching the initial point of vector B to the endpoint of vector A. Now the vector starting at the initial point of A and ending at the endpoint of B has the same length and orientation as the resulting vector.
vector - vector
Subtracts the components of vector B from the corresponding components of vector A. The resulting vector can be constructed geometrically by attaching the endpoint of vector B to the endpoint of vector A. Now the vector starting at the initial point of A and ending at the initial point of vector B has the same length and orientation as the resulting vector.
vector << rotator
Vector local-to-global transformation. Imagine a "view offset" vector, e.g. for the weapon in 1st-person view. Such a vector value describes an offset for when the camera points in positive world X-axis direction, with the camera's "up" direction being the same as the world's "up" direction. Now imagine the camera is oriented a different way and the view offset vector needs to be transformed to world coordinates. This is exactly what OffsetVector << CameraRotation
does.
Often the GetAxes() function is used for the same transformation:
local vector CamX, CamY, CamZ, Result; GetAxes(CameraRotation, CamX, CamY, CamZ); Result = OffsetVector.X * CamX + OffsetVector.Y * CamY + OffsetVector.Z * CamZ;
vector >> rotator
Vector global-to-local transformation. This operation is the reverse of the vector << rotator operator, as it could be used to transform an offset vector from world coordinates to local camera coordinates. The code example would be largely the same, except that GetUnAxes() would be used,
vector == vector
Vector equality operator. Returns True if both vectors have the same length and orientation, which can only be true if their corresponding components are equal.
vector != vector
Vector inequality operator. Returns True if the two vectors differ in length or orientation, which happens if any of the corresponding components are different.
vector *= float
Combined scalar multiply and assign. Multiplies vector A by scalar value B, stores the result in A and returns it.
vector *= vector
Combined vector component multiply and assign. Multiplies the corresponding components of A and B, stores the resulting vector in A and returns is.
vector += vector
Combined vector add and assign. Adds A and B, stores the resulting vector in A and returns it.
vector -= vector
Combined vector subtract and assign. Subtracts B from A, stores the resulting vector in A and returns it.
vector /= float
Combined scalar divide and assign. Divides vector A by scalar B, stores the result in A and returns it.
Rotator operators
float * rotator
Multiplies each component of the rotator with the float value and returns the resulting rotator. This operator probably makes more sense for rotation rates than for object orientations. Note that rotator components are of type int, so the results will have their fractional part truncated.
rotator * float
Same as float * rotator, just with the operands swapped.
rotator / float
Divides each component of the rotator by the float value and returns the resulting rotator. This operator probably makes more sense for rotation rates than for object orientations. Note that rotator components are of type int, so the results will have their fractional part truncated.
rotator + rotator
Adds the corresponding components of the rotators and returns the resulting rotator.
rotator - rotator
Subtracts the component values of B from the corresponding components of A and returns the resulting rotator.
rotator == rotator
Rotator equality. Returns True if the corresponding components of the two rotators have identical values. To compare rotators for orientation, if may be necessary to Normalize() their components first. Sometimes that doesn't work either: for example rot(0,32768,0) != rot(32768,0,32768)
even though these two rotator literals actually have the same effect if used e.g. as camera rotation.
int ClockwiseFrom int
Compares corresponding normalized component values of two rotators and returns True if the shortest rotation direction from A to B would be in clockwise direction, i.e. by incrementing A until it reaches B.
Yes, this is actually an int operator returning a bool result. It is listed here among the rotator operators nonetheless because its use it closely related to rotators.
rotator != rotator
Rotator inequality. Returns True if any corresponding components of the two rotators differ. As mentioned for the ==
operator above, this doesn't necessarily mean that the rotators represent different orientations.
rotator *= float
Combined rotator multiply and assign. Multiplies each component of rotator A by B, stores the result in A and returns it.
rotator += rotator
Combined rotator add and assign. Adds the corresponding components of rotators A and B, stores the result in A and returns it.
rotator -= rotator
Combined rotator subtract and assign. Subtracts the components of rotator B from the corresponding components of A, stores the result in A and returns it.
rotator /= float
Combined rotator divide and assign. Divides each component of rotator A by B, stores the result in A and returns it.
Quat operators
Note: Use Quaternion functions if you want to combine Quat values in more meaningful ways.
Quat + Quat
Adds the two quaternions' corresponding components.
Quat - Quat
Subtracts the components of quaternion B from the corresponding components of quaternion A.
Color operators
color * float
Multiplies the RGB components of the color with the float value and returns the resulting color with the original alpha value. Note that color components are of type byte, so the results will be modulo 256 and have their fractional part truncated.
float * color
Same as color * float, just with the operands swapped.
LinearColor * float
Multiplies the RGB components of the color with the float value and returns the resulting color with the original alpha value.
color + color
Adds the RGB components of the colors and returns the resulting color with the original alpha value of color A. Note that color components are of type byte, so the results will be modulo 256.
color - color
Subtracts the second color's RGB components from the first's and returns the resulting color with the original alpha value of color A. Note that color components are of type byte, so the results will be modulo 256.
LinearColor - LinearColor
Subtracts the second color's RGB components from the first's and returns the resulting color with the original alpha value of color A.
String operators
string < string
Compares the strings case-sensitively and returns True if A comes before B in lexicographical order.
string <= string
Compares the strings case-sensitively and returns True if A is identical to B or comes before B in lexicographical order.
string == string
Case-sensitive string equality. Returns True if A and B contain the exact same characters in exactly the same order.
string > string
Compares the strings case-sensitively and returns True if A comes after B in lexicographical order.
string >= string
Compares the strings case-sensitively and returns True if A is identical to B or comes after B in lexicographical order.
string ~= string
Case-insensitive string equality. Returns True if the two strings are either equal or only differ by case.
string != string
Case-sensitive string inequality. Returns True if the strings do not contain the exact same characters in exactly the same order. This includes different case.
To compare two strings for case-insensitive inequality you can either compare their capitalized versions for inequality (Caps(A) != Caps(B)
) or negate the result of the case-insensitive equality operator (!(A ~= B)
).
string $ string
String concatenation. Returns a string that contains the content of B appended to the content of A: "Hello" $ "World"
results in the string "HelloWorld"
.
string @ string
Spaced string concatenation. Same as string $ string, but the two strings are separated by a space character in the result: "Hello" @ "World"
results in the string "Hello World"
.
string $= string
Combined concate and assign. Appends the content of B to A, stores the result in A and returns it.
string @= string
Combined spaced concate and assign. Appends a space character and the content of B to A, stores the result in A and returns it.
string -= string
Combined string removal and assign. Finds all occurrences of B in A and removes them. The result is stored in A and returned. Occurences of B that are a result of a removal operation are ignored: "aaabbb" -= "ab"
results in "aabb"
.
Name operators
name == name
Name equality. Returns True if A and B represent the same name value.
name != name
Name inequality. Returns True if A and B represent different name value.
Object operators
Interface == Interface
Object equality if interface-type variables are involved.. Returns True if A and B either point to the same object or are both None.
Object == Object
Object equality. Returns True if A and B either point to the same object or are both None.
Interface != Interface
Object inequality if interface-type variables are involved. Returns True if A and B point to different objects or one is None while the other isn't.
Object != Object
Object inequality. Returns True if A and B point to different objects or one is None while the other isn't.