Functions, core hooks, messages and constants for manipulation of game objects. The "go" namespace is accessible from game object script files.
See GoProperties
for related properties.
See GoMessages
for related messages.
Static methods
staticanimate<T>(url:HashOrStringOrUrl, property:HashOrString, playback:GoPlayback, to:GoAnimatedProperty, easing:EitherType<GoEasing, Vector3>, duration:Float, ?delay:Float, ?complete_function:(T, Url, GoAnimatedProperty) ‑> Void):Void
Animates a named property of the specified game object or component.
This is only supported for numerical properties. If the node property is already being animated, that animation will be canceled and replaced by the new one.
If a complete_function
(lua function) is specified, that function will be called when the animation has completed.
By starting a new animation in that function, several animations can be sequenced together. See the examples for more information.
NOTE! If you call go.animate()
from a game object's final()
function, any passed
complete_function
will be ignored and never called upon animation completion.
See the properties guide for which properties can be animated and how.
Parameters:
url | url of the game object or component having the property |
---|---|
property | name of the property to animate |
playback | playback mode of the animation |
to | target property value |
easing | easing to use during animation. Either specify a constant, see the properties guide for a complete list, or a vmath.vector with a curve. |
duration | duration of the animation in seconds |
delay | delay before the animation starts in seconds |
complete_function | function with parameters (self, url, property) to call when the animation has completed |
staticcancel_animations(url:HashOrStringOrUrl, property:HashOrString):Void
Cancels all animations of the named property of the specified game object or component.
By calling this function, all stored animations of the given property will be canceled.
See the properties guide for which properties can be animated and how.
Parameters:
url | url of the game object or component having the property |
---|---|
property | name of the property to animate |
staticdelete(?id:HashOrStringOrUrl, ?recursive:Bool):Void
staticdelete(?id:Table<Int, Hash>, ?recursive:Bool):Void
Delete one or more game objects identified by id. Deletion is asynchronous meaning that
the game object(s) are scheduled for deletion which will happen at the end of the current
frame. Note that game objects scheduled for deletion will be counted against
max_instances
in "game.project" until they are actually removed.
Parameters:
id | optional id or table of id's of the instance(s) to delete, the instance of the calling script is deleted by default |
---|---|
recursive | optional boolean, set to true to recursively delete child hiearchy in child to parent order |
staticget<T>(url:HashOrStringOrUrl, id:Property<T>):T
staticget(url:HashOrStringOrUrl, id:HashOrString):GoProperty
Gets a named property of the specified game object or component.
Parameters:
url | url of the game object or component having the property |
---|---|
id | id of the property to retrieve |
Returns:
the value of the specified property
staticget_id(?path:String):Hash
Returns or constructs an instance identifier. The instance id is a hash of the absolute path to the instance.
If path
is specified, it can either be absolute or relative to the instance of the calling script.
If path
is not specified, the id of the game object instance the script is attached to will be returned.
Parameters:
path | path of the instance for which to return the id |
---|
Returns:
instance id
staticget_position(?id:HashOrStringOrUrl):Vector3
Gets the position of a game object instance.
The position is relative the parent (if any).
Use Go.get_world_position
to retrieve the global world position.
Parameters:
id | optional id of the game object instance to get the position for, by default the instance of the calling script |
---|
Returns:
instance position
staticget_rotation(?id:HashOrStringOrUrl):Quaternion
Gets the rotation of the game object instance.
The rotation is relative to the parent (if any).
Use Go.get_world_rotation
to retrieve the global world position.
Parameters:
id | optional id of the game object instance to get the rotation for, by default the instance of the calling script |
---|
Returns:
instance rotation
staticget_scale(?id:HashOrStringOrUrl):Vector3
Gets the 3D scale factor of the game object instance.
The scale is relative the parent (if any).
Use Go.get_world_scale
to retrieve the global world 3D scale factor.
Parameters:
id | optional id of the game object instance to get the scale for, by default the instance of the calling script |
---|
Returns:
instance scale factor
staticget_scale_uniform(?id:HashOrStringOrUrl):Float
Gets the uniform scale factor of the game object instance.
The uniform scale is relative the parent (if any). If the underlying scale vector is non-uniform the min element of the vector is returned as the uniform scale factor.
Parameters:
id | optional id of the game object instance to get the uniform scale for, by default the instance of the calling script |
---|
Returns:
uniform instance scale factor
staticget_world_position(?id:HashOrStringOrUrl):Vector3
Gets the game object instance world position.
Use Go.get_position
to retrieve the position relative to the parent.
Parameters:
id | optional id of the game object instance to get the world position for, by default the instance of the calling script |
---|
Returns:
instance world position
staticget_world_rotation(?id:HashOrStringOrUrl):Quaternion
Gets the game object instance world rotation.
Use Go.get_rotation
to retrieve the rotation relative to the parent.
Parameters:
id | optional id of the game object instance to get the world rotation for, by default the instance of the calling script |
---|
Returns:
instance world rotation
staticget_world_scale(?id:HashOrStringOrUrl):Vector3
Gets the game object instance world 3D scale factor.
Use Go.get_scale
to retrieve the 3D scale factor relative to the parent.
This vector is derived by decomposing the transformation matrix and should be used with care.
For most cases it should be fine to use Go.get_world_scale_uniform
instead.
Parameters:
id | optional id of the game object instance to get the world scale for, by default the instance of the calling script |
---|
Returns:
uniform instance world scale factor
staticget_world_scale_uniform(?id:HashOrStringOrUrl):Float
Gets the uniform game object instance world scale factor.
Use go.get_scale_uniform
to retrieve the scale factor relative to the parent.
Parameters:
id | optional id of the game object instance to get the world scale for, by default the instance of the calling script |
---|
Returns:
instance world scale factor
staticget_world_transform(?id:HashOrStringOrUrl):Matrix4
Gets the world transform of a game object instance.
Parameters:
id | optional id of the game object instance to get the world transform for, by default the instance of the calling script |
---|
Returns:
instance world transform
staticset<T>(url:HashOrStringOrUrl, id:Property<T>, value:T):Void
staticset(url:HashOrStringOrUrl, id:HashOrString, value:GoProperty):Void
Sets a named property of the specified game object or component.
Parameters:
url | url of the game object or component having the property |
---|---|
id | id of the property to set |
value | the value to set |
staticset_parent(?id:HashOrStringOrUrl, ?parent_id:HashOrStringOrUrl, ?keep_world_transform:Bool):Void
Sets the parent for a game object instance. This means that the instance will exist in the geometrical space of its parent, like a basic transformation hierarchy or scene graph. If no parent is specified, the instance will be detached from any parent and exist in world space.
Parameters:
id | optional id of the game object instance to set parent for, defaults to the instance containing the calling script |
---|---|
parent_id | optional id of the new parent game object, defaults to detaching game object from its parent |
keep_world_transform | optional boolean, set to true to maintain the world transform when changing spaces. Defaults to false. |
staticset_position(position:Vector3, ?id:HashOrStringOrUrl):Void
Sets the position of the game object instance.
The position is relative to the parent (if any). The global world position cannot be manually set.
Parameters:
position | position to set |
---|---|
id | optional id of the game object instance to set the position for, by default the instance of the calling script |
staticset_rotation(rotation:Quaternion, ?id:HashOrStringOrUrl):Void
Sets the rotation of the game object instance.
The rotation is relative to the parent (if any). The global world rotation cannot be manually set.
Parameters:
rotation | rotation to set |
---|---|
id | optional id of the game object instance to get the rotation for, by default the instance of the calling script |
staticset_scale(scale:EitherType<Float, Vector3>, ?id:HashOrStringOrUrl):Void
Sets the scale factor of the game object instance.
The scale factor is relative to the parent (if any). The global world scale factor cannot be manually set.
NOTE! Physics are currently not affected when setting scale from this function.
Parameters:
scale | vector or uniform scale factor, must be greater than 0 |
---|---|
id | optional id of the game object instance to get the scale for, by default the instance of the calling script |