Unit - stingray.Unit object reference - Stingray Lua API Reference

Description

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.

Animation

Parameters

self :

stingray.Unit

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

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.

Parameters

self :

stingray.Unit

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.

  • Unit.ANIMATION_OVERRIDE_PERCENT_SYNC: If supplied, overrides the percent value for percent sync transitions. This allows the script to force the transition into a certain percentage of the destination animation. If you specify this parameter, you must follow it with a number value that specifies the percentage as a value between 0 and 1.
The ? notation indicates that this type is optional: there may be zero or one instances of it.
Returns
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.

Parameters

self :

stingray.Unit

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.

Returns

integer

The index of the constraint target.

Parameters

self :

stingray.Unit

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.

Returns

integer

The index of the specified variable.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Matrix4x4

The value of the constraint target.

Parameters

self :

stingray.Unit

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

Returns

boolean

Does the curve exists.

number

The value of curve evaluation.

Parameters

animation :

string

The name of the animation.

Returns

number

The length of the animation.

Parameters

self :

stingray.Unit

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

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.
Parameters

self :

stingray.Unit

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

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.

Parameters

self :

stingray.Unit

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.

Returns

number

The value of the variable in the unit's animation state machine.

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the constraint target is defined for the unit, or false otherwise.

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the specified unit's animation state machine has the specified variable, or false otherwise.

Parameters

self :

stingray.Unit

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.

Returns

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.

Parameters

self :

stingray.Unit

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

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.

Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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

stingray.Matrix4x4

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).

Parameters

self :

stingray.Unit

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.
Returns

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.

Parameters

self :

stingray.Unit

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.

Returns
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.

Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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
This function does not return any values.

This is typically only used for debugging purposes or by editing tools.

Parameters

self :

stingray.Unit

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
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns

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.

Parameters

self :

stingray.Unit

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

boolean

Returns true if the specified unit has an animation state machine, or false otherwise.

Parameters

self :

stingray.Unit

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

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.

Parameters

self :

stingray.Unit

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:

  • ignore: Bone animations are ignored; they will not affect the unit's bone nodes.
  • transform: Default mode. The bone position, rotation and scale that occur in the animation will be applied to the bone nodes of the Unit.
  • position: only bone positions are transferred to the bone nodes.
  • rotation: only bone rotations are transferred to the bone nodes.
  • scale: only bone scales are transferred to the bone nodes.
  • position_and_rotation: only bone positions and rotations are transferred to the bone nodes.
  • position_and_scale: only bone positions and scales are transferred to the bone nodes.
  • rotation_and_scale: only bone rotations and scales are transferred to the bone nodes.
Returns
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()).

Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.

This method is only available in development mode.

Parameters

self :

stingray.Unit

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:

  • "max_start_time": Sets the maximum time into an animation that we can start, in seconds. If a value of 0.2 is set, it means that if we can find any existing player playing this animation that has played for 0-0.2 seconds, then we will reuse that player instead of creating a new one. The animation will jump to the position where that player is, instead of starting at t=0. If you specify this parameter, you must follow it with a number parameter that provides the time value in seconds. The default value is 0, which allows animation evaluations to be merged only if they began in the same frame.
  • "max_drift": Controls how much the displayed animation time is allowed to drift from the actual animation time. If two animations that are sharing a player are played with different speeds, they will eventually drift apart. At some point the animations will be considered too different and the evaluator will be split in two. This parameter controls when that happens. A value of 0.2 means that if the animations differs more than 0.2 seconds, the evaluator will be split. If you specify this parameter, you must follow it with a number parameter that provides the time value in seconds. The default value is 0.
  • "clock_fidelity": This controls how much the animation will respect the set playing speed. By slightly changing the playing speed of an animation, the animation player can prevent two playing animations from drifting apart and thus forcing a split of the evaluators. A clock fidelity of 0.9 means that the speed will be within 90%% of what has been requested: i.e. it is allowed to change by 10 percent. If you specify this parameter, you must follow it with a number parameter that provides the fidelity as a ratio between 0 and 1. The default value of 1.0 means that the speed will be exactly what has been requested.
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.
Returns
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.

Parameters

self :

stingray.Unit

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:

  • ignore: Default mode. Root animations are ignored; they will not affect the unit's root node. When using this mode, use animation_wanted_root_pose() to extract the position the animation wanted to move the root to, and apply that position programmatically.
  • delta_transform: The delta changes to the root position, rotation and scale that occur in the animation will be applied to the root node of the Unit. The unit's root will be moved by the animation.
  • delta_position: Same as delta_transform, but only position updates are transferred to the root node.
  • delta_rotation: Same as delta_transform, but only rotation updates are transferred to the root node.
  • delta_scale: Same as delta_transform, but only scale updates are transferred to the root node.
  • delta_position_and_rotation: Same as delta_transform, but only position and rotation updates are transferred to the root node.
  • delta_position_and_scale: Same as delta_transform, but only position and scale updates are transferred to the root node.
  • delta_rotation_and_scale: Same as delta_transform, but only rotation and scale updates are transferred to the root node.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns
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.

Bounding boxes

Parameters

self :

stingray.Unit

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.
Returns

stingray.Matrix4x4

The position and rotation of the center of the bounding box.

stingray.Vector3

The half-extents of the bounding box along all three axes.

Cameras

Parameters

self :

stingray.Unit

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.
Returns

stingray.Camera

The specified camera.

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit contains the camera, or false otherwise.

Parameters

self :

stingray.Unit

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

integer

The number of cameras in the unit.

Dynamic Data

Parameters

self :

stingray.Unit

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.
Returns

any

The value previously set at the specified sequence of indices.

Parameters

self :

stingray.Unit

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.
Returns

boolean

Returns true if a data value is stored at the specified sequence of indices, or false otherwise.

Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.

You can retrieve the data later by passing the same indices in a call to get_data().

Flow

Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns

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.

Parameters

self :

stingray.Unit

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.

Returns
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.

Lights

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit contains the light, or false otherwise.

Parameters

self :

stingray.Unit

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.
Returns

stingray.Light

The specifed light.

Parameters

self :

stingray.Unit

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

integer

The number of lights in the unit.

LOD Objects

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit contains the LOD Object, or false otherwise.

Parameters

self :

stingray.Unit

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.
Returns

stingray.LODObject

The specifed LOD Object.

Parameters

self :

stingray.Unit

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

integer

The number of LOD Objects in the unit.

Materials

Parameters

self :

stingray.Unit

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 :

stingray.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.

Returns
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.

Parameters

self :

stingray.Unit

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.
Returns

stingray.IdString64

The resource ID of the material assigned to the slot.

Meshes

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit contains the mesh, or false otherwise.

Parameters

self :

stingray.Unit

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.
Returns

stingray.Mesh

The specified mesh.

Parameters

self :

stingray.Unit

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

integer

The number of meshes in the unit.

Miscellaneous

Parameters

self :

stingray.Unit

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

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.

Parameters

self :

stingray.Unit

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

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.

Parameters

self :

stingray.Unit

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

stingray.IdString64

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.

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit's resource type matches the specified name, or false otherwise.

Parameters

self :

stingray.Unit

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 :

stingray.Vector3

The start position of the raycast.

direction :

stingray.Vector3

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.

Returns

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.

stingray.Vector3?

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.

Parameters

self :

stingray.Unit

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

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.

Physics

Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.

Initial velocities can currently only be set up for physics scene objects exported from a modeling package.

Parameters

self :

stingray.Unit

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
This function does not return any values.

This is typically only used for debugging purposes or by editing tools.

Parameters

self :

stingray.Unit

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
This function does not return any values.

Properties

Parameters

self :

stingray.Unit

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.
Returns

number

The value currently set for the property.

Parameters

self :

stingray.Unit

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.

Returns
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.

Scene Graphs

Parameters

self :

stingray.Unit

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

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.
Parameters

dest_unit :

stingray.Unit

The destination unit to which the scene graph nodes are copied to.

src_unit :

stingray.Unit

The source unit from which the nodes are copied over.

Returns
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.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Matrix4x4

The position and orientation of the node, in global coordinates.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Vector3

The position of the node, in global coordinates.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Quaternion

The rotation of the node, in global coordinates.

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit has a matching node, or false otherwise.

Parameters

self :

stingray.Unit

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

stingray.World

The world the unit lives in.

Parameters

self :

stingray.Unit

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

stingray.Level?

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.
Parameters

self :

stingray.Unit

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.

Returns

stingray.Matrix4x4

The position and orientation of the node.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Vector3

The position of the node.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Quaternion

The rotation of the node.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Vector3

The scale of the node.

Parameters

self :

stingray.Unit

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.

Returns

integer

The index of the object node.

Parameters

self :

stingray.Unit

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

integer

The number of nodes in the unit's scene graph.

Parameters

self :

stingray.Unit

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.

Returns

integer

The index of the parent node, or nil if the node is a root node.

Parameters

self :

stingray.Unit

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 :

stingray.Matrix4x4

The new position and orientation to set for the node.

Returns
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.

Parameters

self :

stingray.Unit

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 :

stingray.Vector3

The new position to set for the node.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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 :

stingray.Quaternion

The new rotation to set for the node.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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 :

stingray.Vector3

The new scale to set for the node.

Returns
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()].

Parameters

self :

stingray.Unit

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 :

stingray.Matrix4x4

The position and orientation set for the node.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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 :

stingray.Vector3

The new position to set for the node.

Returns
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.

Parameters

self :

stingray.Unit

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 :

stingray.Quaternion

The new rotation to set for the node.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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 :

stingray.Vector3

The new scale to set for the node.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns

stingray.Matrix4x4

The position and orientation of the node, in global coordinates.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Vector3

The position of the node, in global coordinates.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Quaternion

The rotation of the node, in global coordinates.

Terrains

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the unit contains the terrain, or false otherwise.

Parameters

self :

stingray.Unit

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

integer

The number of terrains in the unit.

Parameters

self :

stingray.Unit

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.
Returns

stingray.Terrain

The specifed terrain.

Unit Objects

Parameters

self :

stingray.Unit

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.
Returns

stingray.Actor

The specified actor.

Parameters

self :

stingray.Unit

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.
Returns

stingray.Cloth

The specified cloth.

Parameters

self :

stingray.Unit

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

stingray.Actor

Returns the created actor.

Parameters

self :

stingray.Unit

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.
Returns

stingray.Cloth

The newly created cloth.

Parameters

self :

stingray.Unit

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:

  • "actor_1": Specifies the first actor that should be joined by the constraint. Must be followed by a string parameter that specifies the name of the actor.
  • "actor_2": Specifies the second actor that should be joined by the constraint. Must be followed by a string parameter that specifies the name of the actor.
  • "anchor_1": Specifies the first anchor point in local coordinates of the first actor. Must be followed by a Vector3 parameter.
  • "anchor_2": Specifies the second anchor point in local coordinates of the second actor. Must be followed by a Vector3 parameter.
  • "global_anchor": Specifies an anchor point, in global coordinates, that will be used for both the joined actors. Must be followed by a Vector3 parameter.
  • "global_axis": Specifies a constraint axis in global coordinates that will be used for both the joined actors. Must be followed by a Vector3 parameter.
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.
Returns

stingray.Joint

The newly created joint.

Parameters

self :

stingray.Unit

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.

Returns

stingray.Joint

The newly created joint.

Parameters

self :

stingray.Unit

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

stingray.Vehicle

The newly created vehicle.

Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns

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.
Parameters

self :

stingray.Unit

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.

Returns

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.
Parameters

self :

stingray.Unit

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.

Returns

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.
Parameters

self :

stingray.Unit

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

stingray.Mover?

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.
Parameters

self :

stingray.Unit

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 :

stingray.Vector3

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.
Returns

boolean

Returns true if the mover fits at the position, or false otherwise.

stingray.Vector3?

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.
Parameters

self :

stingray.Unit

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

integer

The number of actors in the unit.

Parameters

self :

stingray.Unit

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

integer

The number of cloths in the unit.

Parameters

self :

stingray.Unit

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

integer

The number of movers in the unit.

Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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

stingray.Mover?

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.
Parameters

self :

stingray.Unit

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.

Returns
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.

Parameters

self :

stingray.Unit

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

stingray.Vehicle?

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.

Visibility Groups

Parameters

self :

stingray.Unit

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.

Returns

boolean

Returns true if the visibility group is defined for the unit, or false otherwise.

Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.
Parameters

self :

stingray.Unit

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.

Returns
This function does not return any values.

Visibility groups are declared in the unit's data resource file.

Deprecated

The functions in this section are considered deprecated.

They remain in the engine only for backward compatibility with older projects.

Parameters

name :

string

The name of the material.

Returns

integer

The ID associated with the material.

Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.

The animation is played from the time from to time to.

Parameters

self :

stingray.Unit

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 :

stingray.Vector3

The starting position of the raycast.

end :

stingray.Vector3

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.
Returns

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("").

Parameters

self :

stingray.Unit

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.
Returns
This function does not return any values.