My program doesn't have bugs. It just develops random features.
UE3:Object static native functions (UT3)
Object (static native functions) |
Contents
- 1 Math functions
- 1.1 Int functions
- 1.2 Float functions
- 1.3 Vector and rotator functions
- 1.3.1 ClampLength
- 1.3.2 GetAngularDistance
- 1.3.3 GetAngularFromDotDist
- 1.3.4 GetAxes
- 1.3.5 GetDotDistance
- 1.3.6 GetUnAxes
- 1.3.7 IsZero
- 1.3.8 MirrorVectorByNormal
- 1.3.9 Normal
- 1.3.10 Normalize
- 1.3.11 NormalizeRotAxis
- 1.3.12 OrthoRotation
- 1.3.13 ProjectOnTo
- 1.3.14 RDiff
- 1.3.15 VSize
- 1.3.16 VSize2D
- 1.3.17 VSizeSq
- 1.3.18 VSizeSq2D
- 1.4 Quaternion functions
- 1.5 Interpolation functions
- 2 Random numbers
- 3 String functions
- 4 Debugging
- 5 Other static native functions
- Object static native functions in other games:
- RTNP, U1, UT, U2, U2XMP, UE2Runtime, UT2003, UT2004, UDK
- Other member categories for this class:
- operators, structs
Math functions
Int functions
Clamp
Limits V to the interval of [A, B]. Exactly speaking, A will be returned if V is smaller than A, B will be returned if V is larger than B, otherwise V is returned.
This also applies if A is larger than B. So if V is larger than B, but smaller than A, the value of A is returned even though V is actually between the two values.
Max
Returns the larger of the two values. Note that when passing float parameters to this function, they are automatically typecasted to type int. If you don't want this, use the FMax() function instead.
Min
Returns the smaller of the two values. Note that when passing float parameters to this function, they are automatically typecasted to type int. If you don't want this, use the FMin() function instead.
ToHex
Converts the int value to its corresponding hexadecimal string representation. Values are treated as unsigned 32 bit integer values for conversion, so e.g. ToHex(-2)
results in the string FFFFFFE
.
Float functions
Abs
Returns the absolute value of A. That means, if A is greater than or equal to zero, it is returned unchanged. Otherwise, if A is less than zero, -A is returned.
Acos
Calculates the arccos of A.
Asin
Calculates the arcsin of A.
Atan
Calculates atan2 for the arguments A and B.
Cos
Calculates the cosine of A.
Exp
Calculates e to the power of A, the exponential function.
FClamp
Limits V to the interval of [A, B]. Exactly speaking, A will be returned if V is smaller than A, B will be returned if V is larger than B, otherwise V is returned.
FMax
Returns the larger of the two values.
FMin
Returns the smaller of the two values.
Loge
Calculates the logarithm of A to the base of e, the natural logarithm.
Round
Rounds to the nearest integer value, using "round half to even" as tie-breaker.
Sin
Calculates the sine of A.
Sqrt
Calculates the square root of A.
Square
Calculates A * A, i.e. A squared.
Tan
Calculates the tangent of A.
Vector and rotator functions
ClampLength
Clamps a vector to not be longer than MaxLength.
GetAngularDistance
Calculates the angular distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ).
Orientation: (consider 'O' the first person view of the player, and 'Direction' a vector pointing to an enemy) - positive azimuth means enemy is on the right of crosshair. (negative means left). - positive elevation means enemy is on top of crosshair, negative means below.
Parameters:
- out_AngularDist - X = Azimuth angle (in radians) of 'Direction' vector compared to plane (AxisX,AxisZ). .Y = Elevation angle (in radians) of 'Direction' vector compared to plane (AxisX,AxisY).
- Direction - Direction of target.
- AxisX - X component of reference system.
- AxisY - Y component of reference system.
- AxisZ - Z component of reference system.
Output: true if 'Direction' is facing AxisX (Direction dot AxisX >= 0.f)
GetAngularFromDotDist
Converts Dot distance to angular distance.
Parameters:
- OutAngDist - Angular distance in radians.
- DotDist - Dot distance.
See: GetAngularDistance() and GetDotDistance().
GetAxes
Determines the axis unit vectors of a coordinate system that is created by rotating the world coordinate system as specified by the rotator value. Note that the X value is identical to the rotator value typecasted to vector.
If you think of the rotator value as a camera view rotation, then X points in view direction, Y points to the right and Z points upwards.
GetDotDistance
Calculates the dotted distance of vector 'Direction' to coordinate system O(AxisX,AxisY,AxisZ).
Orientation: (consider 'O' the first person view of the player, and 'Direction' a vector pointing to an enemy) - positive azimuth means enemy is on the right of crosshair. (negative means left). - positive elevation means enemy is on top of crosshair, negative means below.
Parameters:
- OutDotDist - X = 'Direction' dot AxisX relative to plane (AxisX,AxisZ). (== Cos(Azimuth)) .Y = 'Direction' dot AxisX relative to plane (AxisX,AxisY). (== Sin(Elevation))
- Direction - direction of target.
- AxisX - X component of reference system.
- AxisY - Y component of reference system.
- AxisZ - Z component of reference system.
Returns:
- true if 'Direction' is facing AxisX (Direction dot AxisX >= 0.f)
Note: Azimuth' (.X) sign is changed to represent left/right and not front/behind. front/behind is the funtion's return value.
GetUnAxes
Determines the axis unit vectors of a coordinate system that can be transformed into the world coordinate system as specified by rotating it according to the rotator value.
The outputs of GetAxes() and GetUnAxes() for the same input relate to each other as follows: If the output of GetAxes() would be arranged as the column vectors of a 3x3 matrix from left to right, GetUnAxes() would return the row vectors of the same matrix from top to bottom. If the output of both functions would be arranged as column vectors of 3x3 matrices, then the result matrices of GetAxes() and GetUnAxes() are the transpose of each other.
IsZero
Returns whether A is the null vector.
MirrorVectorByNormal
"Reflects" the input vector InVect off a surface with the normal vector InNormal and returns the result. The vector InNormal doesn't actually have to be a unit vector.
Normal
Returns a vector with the same direction as the input value, but a length of 1. The zero vector is just passed through by this function.
Normalize
Normalizes the components of a rotator to the range [-32768, 32767] so the rotator still represents the same orientation.
NormalizeRotAxis
Like Normalize(), but only for one component of a rotator value.
OrthoRotation
Returns a rotator value that represents the coordinate system specified by the three vector values. This is basically the inverse function of GetAxes(). Note that you can also typecast a single vector value to a rotator value with the Roll component being zero.
ProjectOnTo
Projects vector X onto vector Y. The resulting vector will have the same orientation as Y, but most likely a different length and potentially point in the opposite direction if the angle between X and Y is more than 90 degrees.
RDiff
Gives the rotation difference between two Rotators, taking the shortest route between them (in degrees).
VSize
Returns the length of the vector.
VSize2D
Returns the length of the vector, assuming the Z component to be 0.
VSizeSq
Returns the squared length of the vector.
This may seem like a weird idea at first, but a vector's length is calculated via Sqrt(A dot A)
, so the squared length is actually easier to calculate. Comparing squared lengths always has the same result as comparing the actual lengths, so it's a valid replacement if used consistently.
VSizeSq2D
Returns the squared length of the vector, assuming the Z component to be 0.
Quaternion functions
- Main article: Quaternions
QuatDot
QuatFindBetween
Finds the quaternion that describes the smallest rotation that transforms vector A into vector B. The parameters should be unit vectors for this function to return meaningful results.
QuatFromAxisAndAngle
Creates a quaternion that describes a rotation of the specified angle around the given axis vector. The axis vector doesn't need to be normalized.
QuatFromRotator
Converts a rotator to a quaternion so they describe the same rotation.
QuatInvert
Inverts the vector part of the quaternion, i.e. calculates the conjugate of the quaternion. This basically means the result represents a rotation of the same angle, but in the opposite direction.
QuatProduct
Calculates the Hamilton product of the two quaternions.
Note: QuatProduct(Q1, Q2) == -QuatProduct(Q2, Q1)
QuatRotateVector
Applies the rotation described by quaternion A to vector B.
QuatToRotator
Converts the quaternion into a rotator so they describe the same rotation.
Interpolation functions
FCubicInterp
Cubic Spline interpolation.
Parameters:
- P - end points
- T - tangent directions at end points
- Alpha - distance along spline
Returns:
- evaluated value.
FInterpEaseInOut
Interpolates with both ease-in and ease-out (smoothly departs A, smoothly approaches B).
Parameters:
- A - Value to interpolate from.
- B - Value to interpolate to.
- Alpha - Interpolant.
- Exp - Exponent. Higher values result in more rapid acceleration adn deceleration.
Returns:
- Interpolated value.
FInterpTo
Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a position. (Doesn't work well when target teleports)
Parameters:
- Current - Actual position
- Target - Target position
- DeltaTime - time since last tick
- InterpSpeed - Interpolation speed
Returns:
- new interpolated position
Lerp
Performs linear interpolation between A and B.
QuatSlerp
Performs spherical linear interpolation between the quaternions A and B.
RInterpTo
Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a position. (Doesn't work well when target teleports)
Parameters:
- Current - Actual position
- Target - Target position
- DeltaTime - time since last tick
- InterpSpeed - Interpolation speed
Returns:
- new interpolated position
RLerp
Performs linear interpolation between A and B. bShortestPath should be omitted or False for interpolating rotation rates, while it should be True for interpolating orientations.
RSmerp
Performs smooth interpolation between A and B. bShortestPath should be omitted or False for interpolating rotation rates, while it should be True for interpolating orientations.
VInterpTo
Tries to reach Target based on distance from Current position, giving a nice smooth feeling when tracking a location. (Doesn't work well when target teleports)
Parameters:
- Current - Actual location
- Target - Target location
- DeltaTime - time since last tick
- InterpSpeed - Interpolation speed
Returns:
- new interpolated position
VLerp
Performs linear interpolation between A and B.
VSmerp
Performs smooth interpolation between A and B.
Random numbers
FRand
Returns a random float value between 0 and 1.
Rand
Returns a random int value in the range 0 to Max-1. Note that the maximum effective value for Max is 0x7FFF or 32767.
RotRand
Returns a rotator value with random Pitch and Yaw components in the range 0 to 65535. If the parameter bRoll is True, the result's Roll component is also set to a random value in that range. Otherwise, the Roll component is set to zero.
VRand
Returns a unit vector with a random direction.
String functions
Asc
Returns the ASCII value of the first character in the specified string, or 0 if the empty string was specified.
- Note: actually it's not ASCII value, but rather Unicode codepoint.
Caps
Converts all letters in S to uppercase and returns the result.
Chr
Returns a string consisting only of the character with the specified ASCII value. Specifying 0 will result in an empty string.
- Note: same as Asc.
InStr
Returns the position of the first (with bSearchFromRight specified as True: the last) occurrence of S in T or -1 if T does not contain S. This function is case-sensitive. The position of the first character is 0.
Left
Returns the i left-most characters of S. If S has less than or equal to i characters, the entire value is returned.
Len
Returns the number of characters in S, i.e. the length of the string.
Localize
Reads a localized string from the specified section of a localization file. The name of the localization file is given as PackageName, its extension is determined through the Language setting in the [Core.System] section of UTEngine.ini.
Locs
Converts all letters in S to lowercase and returns the result.
Mid
Returns up to j characters from string S, starting with the ith character. If j is omitted or greater than the number of characters after position i, all remaining characters are returned.
ParseStringIntoArray
Breaks up a delimited string into elements of a string array.
Parameters:
- BaseString - The string to break up
- Pieces - The array to fill with the string pieces
- Delim - The string to delimit on
- bCullEmpty - If true, empty strings are not added to the array
Repl
Replaces all occurrences of Match in Src with With and returns the result. Any occurrences created as a result of a replacement are ignored. By default Match is matched case-insensitively, unless bCaseSensitive is specified as True.
Right
Returns the i right-most characters of S. If S has less than or equal to i characters, the entire value is returned.
Debugging
GetFuncName
Returns the current calling function's name, useful for debugging.
GetNetFuncName
Returns the name of the replicated function where script execution began, if the current script was remotely executed
IsNetScript
Returns whether the current script was remotely executed (i.e. through a replicated function) NOTE: Mainly for debugging, not for general usage
IsUTracing
Returns whether script function call trace logging is currently enabled.
ScriptTrace
Dumps the current script function stack to the log file, useful for debugging.
SetUTracing
Enables/disables script function call trace logging.
Other static native functions
ClassIsChildOf
Returns whether TestClass is equal to or a subclass of ParentClass. Returns False if either parameter is None.
DynamicLoadObject
Attempts to load an object of the specified class and with the specified name and returns it on success or ReturnsNone on failure. If MayFail is omitted or False, a warning is logged on failure.
FindObject
Attempts to find an existing object of the specified name and class and returns it on success. Returns None if no object with that name was found or the found object has an incompatible class.
GetEnum
Returns the name of the ith constant in the enum E. Enums should be specified as an object literal for the first parameter. The second parameter can be any numeric or enum value. The result of this function is a name value.
This function is useful to create better log output for enum variables, because a direct typecast of the enum value to string would only result in the string representation of the enum value's index.
GetPerObjectConfigSections
Retrieve the names of sections which contain data for the specified PerObjectConfig class.
Parameters:
- SearchClass - the PerObjectConfig class to retrieve sections for.
- out_SectionNames - will receive the list of section names that correspond to PerObjectConfig sections of the specified class
- ObjectOuter - the Outer to use for determining which file to look in. Specify the same object that is used when creating the PerObjectConfig objects that sections are being retrieved for. (PerObjectConfig data is generally stored in a file named after the Outer used when creating those objects, unless the PerObjectConfig class specifies a config file in its class declaration); specify None to use the transient package as the Outer.
- MaxResults - the maximum number of section names to retrieve
Returns:
- TRUE if the file specified was found and it contained at least 1 section for the specified class
LogInternal
Writes a line to the main log file. The Tag defaults to 'ScriptLog'
if omitted.
Note: You should use the `log macro instead of calling this function directly.
PathName
Returns the full path name of the specified object (including package and groups), ie CheckObject::GetPathName().
StaticClearConfig
Deletes the config file section of this class and reloads the default values of all configurable properties. If a property name was specified, only that property's value is deleted from the config file section.
StaticSaveConfig
Writes the default values of all configurable properties of this class into the corresponding config file section. Values of properties defined as globalconfig are written to the config section of the class that originally declared that property.
TimeStamp
Returns a string containing a system timestamp
WarnInternal
Writes a warning to the main log file. The warning text will have the tag "ScriptWarning" and include the object instance and function and/or state name of the WarnInternal() call.
Note: You should use the `warn macro instead of calling this function directly.