Each Unit object represents a single game unit, such as a character, a building, or another object in a game level.
The Unit is the main organizational object within a game level.
Constructors and accessors
Related sample code
Other related reference items
Related help topics
ANIMATION_OVERRIDE_PERCENT_SYNC : integerOverrides the percent value for percent sync transitions in calls to animation_event().
|
Other related reference items
animation_bone_mode ( self ) : stringRetrieves the current animation bone mode for the entire unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
string |
The current animation bone mode. May be any one of: ignore, transform, position, rotation, scale, position_and_rotation, position_and_scaleor rotation_and_scale. See set_animation_bone_mode() for a description of these modes. |
animation_event ( self, event, parameters )Triggers the specified event in the unit's animation state machine, which may cause a transition to a different animation state.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
event : | string | The name of the animation event. |
parameters : | any? | Can be specified as a sequence of keys and values. Currently, only one parameter is supported.
The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
Call this function only on units that have an animation state machine.
NOTE: This feature should be considered experimental.
Other related reference items
animation_find_constraint_target ( self, name ) : integerRetrieves the index of a constraint target in the unit's animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the constraint target. |
integer |
The index of the constraint target. |
animation_find_variable ( self, name ) : integerFinds the index of a specified variable in the unit's animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the variable. |
integer |
The index of the specified variable. |
animation_get_constraint_target ( self, index ) : stingray.Matrix4x4Retrieves the value of a constraint target from the unit's animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
index : | integer | The index of the constraint target to retrieve. |
The value of the constraint target. |
animation_get_curve_value ( self, object, parameter, float_index ) : boolean, numberRetrieves the current value of the animation curve.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
object : | string | The name of the animated node |
parameter : | string | The name of the animated parameter. |
float_index : | number | Optional; The 0-based float index of within the channel floats that will be returned (from 0 to 3). default is 0 |
boolean |
Does the curve exists. |
number |
The value of curve evaluation. |
animation_get_length ( animation ) : numberRetrieves the length of the animation.
|
animation : | string | The name of the animation. |
number |
The length of the animation. |
animation_get_seeds ( self ) : any(integer)+Retrieves the current seeds of the layers random number generators of the unit animation state machine as a tuple of data.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
any(integer)+ |
The current seeds of the unit animation state machine. The seeds are returned as a series of numbers that are the current seed used by each layer's random number generator. The + notation indicates that there may be one or more instances of the specified type. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
animation_get_state ( self ) : any(integer, nil)+Retrieves the current animation state of the unit as a tuple of data.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
any(integer, nil)+ |
The current animation state of the unit. The state is returned as a series of numbers that indicate the current state for each layer. For layers that are not playing a state, nil is returned. The + notation indicates that there may be one or more instances of the specified type. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
You can restore the state later by calling animation_set_state() and passing the same series of values. Note that the state only includes the state of the state machine, not the play head offsets, animation variables or constraint targets.
Other related reference items
animation_get_variable ( self, index ) : numberRetrieves the value of a specified variable from the unit's animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
index : | integer | The index of the variable. |
number |
The value of the variable in the unit's animation state machine. |
animation_has_constraint_target ( self, name ) : booleanReturns true if the constraint target is defined for the unit, or false otherwise.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the constraint target. |
boolean |
Returns true if the constraint target is defined for the unit, or false otherwise. |
animation_has_variable ( self, name ) : booleanIndicates whether or not the unit's animation state machine has the specified variable.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the variable. |
boolean |
Returns true if the specified unit's animation state machine has the specified variable, or false otherwise. |
animation_layer_info ( self, layer ) : number, numberRetrieves information about the animation playing in the specified layer.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
layer : | integer | The index of the animation layer. |
number |
The current time of the animation. |
number |
The total length of the animation. |
You can figure out the percentage of the animation that has played by dividing the returned time value by the returned length value: time / length.
Note: This feature should be considered experimental.
animation_root_mode ( self ) : stringRetrieves the current animation root mode.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
string |
The current animation root mode. May be any one of: ignore, delta_transform, delta_position, delta_rotation, delta_scale, delta_position_and_rotation, delta_position_and_scale or delta_rotation_and_scale. See set_animation_root_mode() for a description of these modes. |
animation_set_constraint_target ( self, index, value )Sets the value of a constraint target in the unit's animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
index : | integer | The index of the constraint target to set. |
value : | any(stingray.Matrix4x4, stingray.Quaternion, stingray.Vector3) | The new value to set for the constraint target. Can be a Matrix4x4, a Quaternion or a Vector3, depending on whether you want to set both the position and rotation or just one of them. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
This function does not return any values. |
animation_set_seeds ( self, seeds )set seeds to Layers random number generator in the animation controller of the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
seeds : | integer+ | The seeds to set to Layer's random number generator in the animation state machine of the unit. The + notation indicates that there may be one or more instances of the specified type. |
This function does not return any values. |
animation_set_state ( self, state )Restores a state fetched with animation_get_state().
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
state : | integer+ | The animation state to set for the unit. The + notation indicates that there may be one or more instances of the specified type. |
This function does not return any values. |
Other related reference items
animation_set_variable ( self, index, value )Sets the value of a specified variable in the unit's animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
index : | integer | The index of the variable whose value you want to set. |
value : | number | The new value tp set for the variable in the unit's animation state machine. |
This function does not return any values. |
animation_wanted_root_pose ( self ) : stingray.Matrix4x4In the ignore root mode, this function returns the position and rotation that the animation would have moved the root node to.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
The pose of the root node. |
You can use this value to apply the animation movement manually from your script, or pass it through other systems (such as the unit's mover, etc).
Other related reference items
crossfade_animation ( self, animation, layer, blend_time, loop, blend_type ) : integerCrossfades in the animation on the specified unit in the specified animation layer over the specified blend time.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
animation : | string | The name of the animation. |
layer : | integer? | The index of the animation layer to use. Optional; default value is 1. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
blend_time : | number? | Time for the crossfade. Optional; default value is 0. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
loop : | boolean? | If true, the animation will loop in the specified time interval; if false the unit will remain in the last pose. Optional; default value is true. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
blend_type : | string? | Specifies how an animation should be blended with other animations, values may be normal and offset. Optional; default value is normal. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
integer |
An id that you can use to control the animation. |
Call this function only on units that have an animation blender but no animation state machine: i.e., units with a script-driven blender.
Other related reference items
crossfade_animation_set_speed ( self, id, speed )Sets the speed at which the crossfaded animation will play with respect to the blender.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | integer | The ID of the crossfaded animation. |
speed : | number | The speed at which the animation should play. |
This function does not return any values. |
A value of 1 means it uses the same time step as the blender. A value of 0 means it is frozen. You cannot use negative values for the speed.
crossfade_animation_set_time ( self, id, time, cap_to_range )Explicitly sets the time of the crossfaded animation to the specified time.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | integer | The ID of the crossfaded animation. |
time : | number | The time to set for the animation. |
cap_to_range : | boolean | if true, the given time will be capped to be in the time range of the animation. Optional; default value is false. |
This function does not return any values. |
disable_animation_state_machine ( self )Disables the unit's animation state machine, so that you can control its blender directly with crossfade_animation() and its related functions.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
This function does not return any values. |
This is typically only used for debugging purposes or by editing tools.
enable_animation_state_machine ( self )Enables the animation state machine for the unit, if it has been previously disabled.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
This function does not return any values. |
has_animation_event ( self, event ) : booleanIndicates whether or not the specified unit has the named animation event.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
event : | string | The name of the animation event. |
boolean |
Returns true if the specified unit has the named animation event, or false otherwise. |
Call this function only on units that have an animation state machine.
has_animation_state_machine ( self ) : booleanIndicates whether or not the specified unit has an animation state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
boolean |
Returns true if the specified unit has an animation state machine, or false otherwise. |
is_crossfading_animation ( self ) : booleanIndicates whether or not the unit is currently crossfading any animation.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
boolean |
Returns true if the unit is currently crossfading any animation, or false otherwise. |
This can be used to avoid overlaying too many crossfading animations on top of each other.
set_animation_bone_mode ( self, mode )Sets the way animations can update the bone nodes of a unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
mode : | string | The animation bone mode to set. Possible values include:
|
This function does not return any values. |
All bones will follow the same update mode, except root node which mode is set separately (see set_animation_root_mode()).
Other related reference items
set_animation_logging ( self, enabled )Determines whether or not animation state machine events will be logged to the command console.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
enabled : | boolean | Use true to enable logging of state machine events, or false to disable. |
This function does not return any values. |
This method is only available in development mode.
set_animation_merge_options ( self, parameters )Controls the settings used to merge evaluations of the same animation that are playing close in time.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
parameters : | any(string, number)+ | The merge options for the animation playing. Possible parameters are:
The + notation indicates that there may be one or more instances of the specified type. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
This function does not return any values. |
The Stingray engine has an optimization system that can merge evaluations of the same animation played close together in time. This can improve performance when there are multiple instances of the same animation playing. This function allows you to control the merge settings.
NOTE: This feature should be considered experimental, and may be subject to change.
set_animation_root_mode ( self, mode )Sets the way in which animations can update the root node of a unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
mode : | string | The animation root mode to set. Possible values include:
|
This function does not return any values. |
Other related reference items
set_animation_state_machine ( self, machine )Sets the animation state machine of the unit to something other than the default.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
machine : | string | The name of the state machine resource to use. |
This function does not return any values. |
set_bones_lod ( self, lod_level )Sets the LOD level for animation bones.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
lod_level : | integer | The new LOD level to set for bones. |
This function does not return any values. |
The LOD level determines which bones in the animation will be evaluated. Bones that are not evaluated will freeze in local space. This can be used to reduce the animation cost of units that are far away from the camera.
The LOD levels for bones are defined in the Unit Editor.
box ( self, ignore_invisble_meshes ) : stingray.Matrix4x4, stingray.Vector3Retrieves an oriented bounding box that encloses all the meshes in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
ignore_invisble_meshes : | boolean? | If true, discard the invisible mesh in the box computation. Default to false. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
The position and rotation of the center of the bounding box. | |
The half-extents of the bounding box along all three axes. |
camera ( self, camera ) : stingray.CameraRetrieves the specified camera owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
camera : | any(integer, string) | The index or name of the camera to retrieve. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specified camera. |
Related sample code
has_camera ( self, camera ) : booleanIndicates whether or not the unit contains a camera with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
camera : | string | The name of the camera. |
boolean |
Returns true if the unit contains the camera, or false otherwise. |
num_cameras ( self ) : integerRetrieves the number of cameras in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of cameras in the unit. |
get_data ( self, indices ) : anyRetrieves the data set at the specified indices within the unit's script data object from the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
indices : | any(integer, string)+ | One or more indices for the data, which may be integers or strings. The + notation indicates that there may be one or more instances of the specified type. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
any |
The value previously set at the specified sequence of indices. |
Other related reference items
has_data ( self, indices ) : booleanIndicates whether or not any data has been saved at the specified indices in the unit's script data object.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
indices : | any(integer, string)+ | One or more indices for the data, which may be integers or strings. The + notation indicates that there may be one or more instances of the specified type. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
boolean |
Returns true if a data value is stored at the specified sequence of indices, or false otherwise. |
Other related reference items
set_data ( self, indices, indices, indices, value ) set_data ( self, indices, indices, value ) set_data ( self, indices, value )Stores the specified value in the unit's script data object, at a location determined by the specified indices.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
indices : | any(integer, string) | One or more indices for the data, which may be integers or strings. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
value : | any | The value to store. |
This function does not return any values. |
You can retrieve the data later by passing the same indices in a call to get_data().
Other related reference items
flow_event ( self, name )Triggers the External In Event node with the specified name in the unit's flow graph.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the flow event to trigger. |
This function does not return any values. |
flow_variable ( self, name ) : anyReturns the value of the External Output flow variable with the specified name in the unit flow.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the external flow variable to retrieve. |
any |
The value of the flow variable. The type of this value depends on the type of the External Output variable that matches the specified name. |
Note that this function works with the external variable Flow nodes, which you can find under the **External > Output** category. It is not related to the nodes under the Variables category, which can only be set and retrieved in Flow graphs.
Note: A variable shown as "My Unit" in the editor has the real name: my_unit.
set_flow_variable ( self, name, value )Sets the value of the the External Input flow variable with the specified name in the unit flow.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the external flow variable to set. |
value : | any | The new value to set for the flow variable. The type of this value depends on the type of the External Input variable that matches the specified name. |
This function does not return any values. |
Note that this function works with the external variable Flow nodes, which you can find under the **External > Input** category. It is not related to the nodes under the Variables category, which can only be set and retrieved in Flow graphs.
has_light ( self, light ) : booleanIndicates whether or not the unit contains a light with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
light : | string | The name of the light. |
boolean |
Returns true if the unit contains the light, or false otherwise. |
light ( self, light ) : stingray.LightRetrieves the specified light owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
light : | any(string, integer) | The name or index of the light to retrieve. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specifed light. |
num_lights ( self ) : integerRetrieves the number of lights in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of lights in the unit. |
has_lod_object ( self, lod ) : booleanIndicates whether or not the unit contains an LOD Object with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
lod : | string | The name of the LOD Object. |
boolean |
Returns true if the unit contains the LOD Object, or false otherwise. |
lod_object ( self, lod ) : stingray.LODObjectRetrieves the specified LOD Object owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
lod : | any(string, integer) | The name or index of the LOD Object to retrieve. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specifed LOD Object. |
num_lod_objects ( self ) : integerRetrieves the number of LOD Objects in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of LOD Objects in the unit. |
set_light_material ( self, light, material_resource )Assigns a material resource to a specified light source within the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
light : | The stingray.Light whose material you want to change. Must be owned by this unit. | |
material_resource : | string | The name of the .material resource you want to assign to the light. |
This function does not return any values. |
Note that the shader graph for the specified material must use the **Output > Light Base** node to produce the color that the light will project.
set_material ( self, slot_name, material_resource ) : stingray.IdString64Assigns a material resource to a specified material slot within the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
slot_name : | string | The name of the slot whose material you want to set. |
material_resource : | string? | The name of the .material resource you want to assign to the slot. If this value is nil, the slot is cleared. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
The resource ID of the material assigned to the slot. |
has_mesh ( self, mesh ) : booleanIndicates whether or not the unit contains a mesh with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
mesh : | string | The name of the mesh. |
boolean |
Returns true if the unit contains the mesh, or false otherwise. |
mesh ( self, mesh ) : stingray.MeshRetrieves the specified mesh owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
mesh : | any(string, integer) | The name or index of the mesh to retrieve. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specified mesh. |
num_meshes ( self ) : integerRetrieves the number of meshes in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of meshes in the unit. |
alive ( self ) : booleanIndicates whether the unit exists, or whether it has been deleted.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
boolean |
Returns false if the unit has been deleted or if the unit is nil. |
Units are always held as weak references. You can call Unit.alive() on any unit to check that the reference is still valid. Calling any function other than alive() on a unit that has been deleted will result in a script error.
Note: only units are held as weak references. You cannot call alive() on any other objects to detect if they have been deleted.
debug_name ( self ) : stringRetrieves the name of the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
string |
The name of the unit. |
This should only be used to print the name for debugging purposes. In release versions the real name will not be available, and this function will return a hexadecimal string instead of the name.
id ( self ) : stingray.IdString64Retrieves a unique ID for the unit within its level.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
The numeric ID of the unit within its level if the unit was placed in the level in the editor, or nil if the unit was spawned dynamically. |
This ID will remain the same even if the level file is modified. It roughly corresponds to the unit's object ID in the level file. If the unit is spawned through a nested level, the ID is a function of the nested level instance ID and the unit object IDs below it. Thus, every unit spawned through a level will have a unique ID in the world.
is_a ( self, name ) : booleanIndicates whether or not the unit is a resource of type name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of a unit resource type. |
boolean |
Returns true if the unit's resource type matches the specified name, or false otherwise. |
mesh_pick_raycast ( self, from, direction, length, include_hidden_meshes ) : number?, stingray.Vector3?, integer?, integer?Tests for ray intersections with visual meshes within the provided Unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
from : | The start position of the raycast. | |
direction : | The direction that the ray will be cast from its starting point as a unit vector. | |
length : | number | The length of the ray. |
include_hidden_meshes : | boolean | Specifies whether the raycast should hit hidden meshes or not. |
number? |
The distance of the collision point from the starting point of the collision test. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
The normal of the surface that was hit. The ? notation indicates that this type is optional: there may be zero or one instances of it. | |
integer? |
The index of the mesh. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
integer? |
The index of the triangle. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
If a mesh triangle is hit, the function returns the mesh index and the index of the intersected triangle within the mesh along with the world normal of the triangle hit. If no triangle is hit, the function doesn't return anything.
Note: Will be very expensive for units containing high density meshes.
name_hash ( self ) : stringRetrieves a hashed representation of the unit name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
string |
The hash representation of the unit name. |
The representation will not be meaningful, but it can be passed as an argument to World.spawn_unit() in order to create another unit of the same type.
apply_initial_actor_velocities ( self, wake_sleeping_actors )Applies any initial velocities that have been defined for actors inside this unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
wake_sleeping_actors : | boolean | Determines whether or not sleeping actors should be awakened when the effect is applied. Optional; default value is true. If set to false, velocities will still be applied to sleeping actors, but the effect will not be apparent until an external event wakes the actors up. |
This function does not return any values. |
Initial velocities can currently only be set up for physics scene objects exported from a modeling package.
disable_physics ( self )Disables all physics for the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
This function does not return any values. |
This is typically only used for debugging purposes or by editing tools.
enable_physics ( self )Re-enables the physics system for the unit, if it has been previously disabled.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
This function does not return any values. |
get_property ( self, properties ) : numberRetrieves the value of a property on a unit, or on any object owned by the unit, such as a material, mesh or light.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
properties : | any(string) | A sequence of strings which together make up the path to the property. See set_property() for details. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
number |
The value currently set for the property. |
set_property ( self, properties, properties, properties, value ) set_property ( self, properties, properties, value ) set_property ( self, properties, value )Sets the value of a property on a unit, or on any object owned by the unit, such as a material, mesh or light.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
properties : | string | A sequence of strings which together make up the path to the property. |
value : | number | The value to set for the property. |
This function does not return any values. |
The properties can take multiple string arguments, which together make up the path to the property. For example, you might write:
stingray.Unit.set_property(myUnit, "meshes", "my_unit_mesh_name", "materials", "slot_name", "albedo", "x", 0.25)
This example would set the red component of the albedo color of a material on the unit.
Note that these paths are the same as the ones used in the curve editor tree view in the StoryTeller.
Other related reference items
bones ( self ) : string[]Retrieves a list of all bones in the unit's state machine.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
string[] |
A list of bone names in the unit's state machine. The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown. |
copy_scene_graph_local_from ( dest_unit, src_unit )Copies all local matrices from the source unit src_unit to the destination unit dest_unit, except for the root node.
|
dest_unit : | The destination unit to which the scene graph nodes are copied to. | |
src_unit : | The source unit from which the nodes are copied over. |
This function does not return any values. |
This can be used to support "instancing", where an expensive unit is simulated and then its transforms are copied to simpler units.
delta_pose ( self, i ) : stingray.Matrix4x4Retrieves the delta world position and orientation of a node in the unit since the last frame.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The position and orientation of the node, in global coordinates. |
delta_position ( self, i ) : stingray.Vector3Retrieves the delta world position of a node in the unit since the last frame.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The position of the node, in global coordinates. |
delta_rotation ( self, i ) : stingray.QuaternionRetrieves the delta world rotation of a node in the unit since the last frame.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The rotation of the node, in global coordinates. |
has_node ( self, name ) : booleanIndicates whether or not the unit has an object node that matches the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the node to look for. |
boolean |
Returns true if the unit has a matching node, or false otherwise. |
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
The world the unit lives in. |
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
The level that spawned the unit, or nil if the unit does not belong to a level. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Related sample code
local_pose ( self, i ) : stingray.Matrix4x4Retrieves the local position and orientation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The position and orientation of the node. |
Other related reference items
local_position ( self, i ) : stingray.Vector3Retrieves the local position of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The position of the node. |
Related sample code
local_rotation ( self, i ) : stingray.QuaternionRetrieves the local rotation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The rotation of the node. |
local_scale ( self, i ) : stingray.Vector3Retrieves the local scale of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The scale of the node. |
Related sample code
node ( self, name ) : integerRetrieves the index of the object node that matches the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the node to retrieve. |
integer |
The index of the object node. |
num_scene_graph_items ( self ) : integerRetrieves the number of nodes in the unit's scene graph.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of nodes in the unit's scene graph. |
scene_graph_link ( self, i, parent )Links the scene graph node i to the scene graph node parent.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the scene graph node that will be linked to a new parent. |
parent : | integer? | The new parent scene graph node, or nil to unlink i from any parents. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
Note that you can only link objects to earlier objects in the scene graph: i.e. objects with a lower index.
Other related reference items
scene_graph_parent ( self, i ) : integerRetrieves the parent of a node in the unit's scene graph.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node in the scene graph whose parent node will be retrieved. |
integer |
The index of the parent node, or nil if the node is a root node. |
set_local_pose ( self, i, pose )Sets the local position and orientation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
pose : | The new position and orientation to set for the node. |
This function does not return any values. |
If you want to change just the rotation or scale of a node, use set_local_rotation() and set_local_scale(). If you use local_pose() to fetch the current pose, modify the rotation or scale of that matrix, and then pass the resulting matrix to set_local_pose(), you will lose some floating point precision in the values.
Related sample code
set_local_position ( self, i, position )Sets the local position of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
position : | The new position to set for the node. |
This function does not return any values. |
Other related reference items
set_local_rotation ( self, i, rotation )Sets the local rotation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
rotation : | The new rotation to set for the node. |
This function does not return any values. |
Related sample code
Other related reference items
set_local_scale ( self, i, scale )Sets the local scale of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
scale : | The new scale to set for the node. |
This function does not return any values. |
If your unit has active physics actor, scaling it will not scale its actors. Scaling the actors too depends on their type: 1. if this is a ragdoll, just deactivate it, scale your unit, reactivate the ragdoll 2. for other cases (e.g. vehicle), you must unspawn the unit and respawn a new one specifying the scale into the pose matrix (see World.spawn_unit()].
Other related reference items
teleport_local_pose ( self, i, pose )Teleports the position and orientation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
pose : | The position and orientation set for the node. |
This function does not return any values. |
teleport_local_position ( self, i, position )Similar to set_local_position(), but the node is teleported rather than moved to the specified location.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
position : | The new position to set for the node. |
This function does not return any values. |
This affects how keyframed physics objects behave. When objects are moved, they will collide with everything between the current position and the destination. When they are teleported, they will pop up at the destination without colliding with objects on the way there.
teleport_local_rotation ( self, i, rotation )Teleports the rotation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
rotation : | The new rotation to set for the node. |
This function does not return any values. |
teleport_local_scale ( self, i, scale )Teleports the scale of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
scale : | The new scale to set for the node. |
This function does not return any values. |
world_pose ( self, i ) : stingray.Matrix4x4Retrieves the world position and orientation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The position and orientation of the node, in global coordinates. |
Related sample code
world_position ( self, i ) : stingray.Vector3Retrieves the world position of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The position of the node, in global coordinates. |
world_rotation ( self, i ) : stingray.QuaternionRetrieves the world rotation of a node in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
i : | integer | The index of the node. |
The rotation of the node, in global coordinates. |
has_terrain ( self, terrain ) : booleanIndicates whether or not the unit contains a terrain with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
terrain : | string | The name of the terrain. |
boolean |
Returns true if the unit contains the terrain, or false otherwise. |
num_terrains ( self ) : integerRetrieves the number of terrains in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of terrains in the unit. |
terrain ( self, terrain ) : stingray.TerrainRetrieves the specified terrain owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
terrain : | any(string, integer) | The name or index of the terrain to retrieve. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specifed terrain. |
actor ( self, actor ) : stingray.ActorRetrieves the specified actor owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
actor : | any(string, integer) | The name or index of the actor to retrieve. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specified actor. |
cloth ( self, cloth ) : stingray.ClothRetrieves the Apex cloth with the specified name or index from the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
cloth : | any(string, integer) | The name or index of the cloth. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The specified cloth. |
create_actor ( self, id, inherit_velocity ) : stingray.ActorCreates an Actor with the specified name or index in the unit, if it has not been created already.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | any(string, integer) | Specifies either the name or index of the actor. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
inherit_velocity : | number? | Optional; specifies to what extent the physics actor should inherit the velocity of the animated objects that it is connected to. A value of 1.0 means it completely inherits the animated velocity. Default value is 0.0. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Returns the created actor. |
create_cloth ( self, id ) : stingray.ClothCreates an Apex cloth with the specified name or index in the unit, if it has not been created already.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | any(string, integer) | The name or index of the new cloth. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The newly created cloth. |
create_custom_joint ( self, name, params ) : stingray.JointCreates a physics joint in the unit based on a joint description.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the joint to create. |
params : | any(string, stingray.Vector3)+ | A list of parameters to configure the joint. The parameter list is a sequence of strings followed by arguments. The following arguments are supported:
The + notation indicates that there may be one or more instances of the specified type. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
The newly created joint. |
create_joint ( self, name ) : stingray.JointCreates a physics joint with the specified name, if it has not been created already in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the joint to create. |
The newly created joint. |
create_vehicle ( self ) : stingray.VehicleCreates a Vehicle in the unit, if it has not been created already.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
The newly created vehicle. |
destroy_actor ( self, actor )Destroys the actor with the specified name or index, if it has been created previously in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
actor : | any(string, integer) | The name or index of the actor. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
This function does not return any values. |
destroy_cloth ( self, id )Destroys an Apex cloth with the specified name or index, if it has been created previously in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | any(string, integer) | The name or index of the cloth to destroy. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
This function does not return any values. |
destroy_joint ( self, name )Destroys a joint with the specified name, if it has been created previously in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the joint to destroy. |
This function does not return any values. |
destroy_vehicle ( self )Destroys the unit's Vehicle, if one exists.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
This function does not return any values. |
find_actor ( self, name ) : integer?Retrieves the index of the actor with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name to the actor to search for. |
integer? |
The index of the actor, or nil if there is no matching actor. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
find_cloth ( self, name ) : integer?Retrieves the index of the Apex cloth with the specified name in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the cloth to search for. |
integer? |
The index of the cloth in the unit, or nil if no matching cloth exists. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
find_mover ( self, name ) : integer?Retrieves the index of the Mover with the specified name.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
name : | string | The name of the mover to search for. |
integer? |
The index of the mover, or nil if no matching mover exists. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
mover ( self ) : stingray.Mover?Retrieves the unit's current physics mover, if any.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
Returns the current mover for the unit, or nil if the unit has no active mover. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
mover_fits_at ( self, id, position, allow_move ) : boolean, stingray.Vector3?Indicates whether or not the mover fits at the specified position without colliding with any world geometry.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | any(string, integer) | The name or index of the mover. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
position : | The position to place the mover. | |
allow_move : | number? | If non-zero, specifies the distance to search for a non-colliding position. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
boolean |
Returns true if the mover fits at the position, or false otherwise. |
If a non-colliding position was found, it is returned as the second paramter. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
num_actors ( self ) : integerRetrieves the number of actors owned by the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of actors in the unit. |
num_cloths ( self ) : integerRetrieves the number of Apex cloths in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of cloths in the unit. |
num_movers ( self ) : integerRetrieves the number of movers in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
integer |
The number of movers in the unit. |
set_cloth_visibilty ( self, id, visibility, context )Sets the visibility of the Apex cloth with the specified name or index.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
id : | any(string, integer) | The name or index of the cloth. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
visibility : | boolean | Use true to make the cloth visible, or false to make it hidden. |
context : | string? | Optional; can be used to toggle visibility separately for each culling context. Valid values for the context are: default, shadow_caster or occluder. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
set_mover ( self, mover ) : stingray.Mover?Sets the unit to use the mover with the specified name or index.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
mover : | any(string, integer)? | The name or index of the mover. If nil, the unit's current mover is disabled. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Returns the mover now set for the unit, or nil if the mover was disabled. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
set_moving ( self, frames )Marks the unit as moving for the specified number of frames, meaning that the world will update the unit's position automatically.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
frames : | integer | Number of frames in the animation. |
This function does not return any values. |
You don't need to mark the unit as moving in cases where you call one of the set_local...() functions on the unit, because those functions automatically mark the unit as moving. However, if you do some other special processing on the unit, you may need to call this function.
Note: Currently this function is not required. It is a tradeoff between speed and convenience if all operations that change a unit should automatically set it as moving, or if the gameplay programmer has to do that explicitly.
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. |
The unit's vehicle, or nil if the unit has no vehicle. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
Related sample code
has_visibility_group ( self, group ) : booleanIndicates whether or not the specified visibility group is declared in the unit's data resource file.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
group : | string | The name of the visibility group. |
boolean |
Returns true if the visibility group is defined for the unit, or false otherwise. |
set_mesh_visibility ( self, mesh, visibility, context )Sets the visibility of the specified Mesh.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
mesh : | any(string, integer) | The name or index of the mesh. The any(...) notation indicates that this item may be an instance of any of the types shown in the parentheses. |
visibility : | boolean | Use true if the objects should be visible, or false otherwise. |
context : | string? | Optional; you can use this to set the visibility separately for each culling context. Valid values are: default, shadow_caster, occluder. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
set_unit_visibility ( self, visibility )Sets the visibility of all meshes in the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
visibility : | boolean | Use true if the unit should be visible, or false otherwise. |
This function does not return any values. |
set_visibility ( self, group, visibility )Sets the visibility of all objects included in the specified visibility group.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
group : | string | The name of the visibility group to modify. |
visibility : | boolean | Use true if the objects should be visible, or false otherwise. |
This function does not return any values. |
Visibility groups are declared in the unit's data resource file.
The functions in this section are considered deprecated.
They remain in the engine only for backward compatibility with older projects.
material_id ( name ) : integerRetrieves the ID for the material with the specified name, to be used in conjunction with query_material().
|
name : | string | The name of the material. |
integer |
The ID associated with the material. |
play_simple_animation ( self, from, to, loop, speed, group )Plays the simple animation track stored in the unit (exported from your digital content creation tool such as Maya or 3ds Max).
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
from : | number? | The start time at which the animation begins playing. Optional; default value is nil. Use nil to start the animation at the current time. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
to : | number? | The end time until which the animation is played. Optional; default value is nil. Use nil to play to the end of the animation. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
loop : | boolean? | If true, the animation will loop in the specified time interval. Optional; default value is false. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
speed : | number? | Used to control the playback speed. Optional; default value is 1. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
group : | string? | If specified, this simple animation group is played; otherwise, the simple animation affects all nodes in the unit. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |
The animation is played from the time from to time to.
query_material ( self, start, end, contexts ) : integer[]Finds the closest intersection by doing a raycast from start to end, and returns a list with one material ID per context.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
start : | The starting position of the raycast. | |
end : | The ending position of the raycast. | |
contexts : | string[] | A table that contains the material contexts. The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown. |
integer[] |
A list with one material ID per context. The [] notation indicates that this type is an array: a table in which the keys of the members are sequential integers, and the value of each element is an instance of the type shown. |
If no material is found for a context, 0 is returned in that slot, which corresponds to material_id("").
Other related reference items
stop_simple_animation ( self, group )Stops a simple animation playing for the unit.
|
self : | Specifies the object instance that this function will act on. You must always provide this self parameter when you call this function. You must use the dot . calling syntax, not the object-oriented colon : calling syntax.For more information, see this Stingray help topic, or this page in the Lua documentation. | |
group : | string? | If specified, this simple animation group is stopped, otherwise stopping the simple animation affects all nodes in the unit. The ? notation indicates that this type is optional: there may be zero or one instances of it. |
This function does not return any values. |