- 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
staticinlineanimate<T>(url:HashOrStringOrUrl, property:Property<T>, playback:GoPlayback, to:T, easing:EitherType<GoEasing, Vector>, duration:Float, delay:Float = 0, ?completeFunction:(Url, Property<T>) ‑> 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 |
completeFunction | function with parameters (url, property) to call when the animation has completed |
staticcancelAnimations<T>(url:HashOrStringOrUrl, ?property:Property<T>):Void
staticcancel_animations(url:HashOrStringOrUrl, ?property:Null<HashOrString>):Void
- Cancels all animations of the named property of the specified game object or component.
By calling this function, all or specified stored property animations of the game object or component will be canceled. See the properties guide for which properties can be animated and the animation guide for how to animate them..
Parameters:
url | url of the game object or component having the property |
|---|---|
property | optional id of the property to cancel |
staticdelete(?id:Null<HashOrStringOrUrl>, ?recursive:Bool):Void
staticdelete(?ids:LuaArray<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_instancesin "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 |
staticexists(url:HashOrStringOrUrl):Bool
- Check if the specified game object exists.
Parameters:
url | url of the game object to check |
|---|
Returns:
true if the game object exists
staticget<T>(url:HashOrStringOrUrl, id:Property<T>, ?options:Null<AnyTable>):T
staticget(url:HashOrStringOrUrl, id:HashOrString, ?options:Null<AnyTable>):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 |
options | (optional) options table - index integer index into array property (1 based) - key hash name of internal property |
Returns:
the value of the specified property
staticgetId(?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
staticgetParent(?id:Null<HashOrStringOrUrl>):Hash
- Get the parent for a game object instance.
Parameters:
id | optional id of the game object instance to get parent for, defaults to the instance containing the calling script |
|---|---|
parent | instance or nil |
staticgetPosition(?id:Null<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
staticgetRotation(?id:Null<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
staticgetScale(?id:Null<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
staticgetScaleUniform(?id:Null<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
staticgetWorldPosition(?id:Null<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
staticgetWorldRotation(?id:Null<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
staticgetWorldScale(?id:Null<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
staticgetWorldScaleUniform(?id:Null<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
staticgetWorldTransform(?id:Null<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, ?options:Null<AnyTable>):Void
staticset(url:HashOrStringOrUrl, id:HashOrString, value:GoProperty, ?options:Null<AnyTable>):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 |
options | (optional) options table - index integer index into array property (1 based) - key hash name of internal property |
value | the value to set |
staticsetParent(?id:Null<HashOrStringOrUrl>, ?parent_id:Null<HashOrStringOrUrl>, ?keepWorldTransform: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 |
keepWorldTransform | optional boolean, set to true to maintain the world transform when changing spaces. Defaults to false. |
staticsetPosition(position:Vector3, ?id:Null<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 |
staticsetRotation(rotation:Quaternion, ?id:Null<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 |
staticsetScale(scale:EitherType<Float, Vector3>, ?id:Null<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 |
staticsetScaleXY(scale:EitherType<Float, Vector3>, ?id:Null<HashOrStringOrUrl>):Void
- Sets the XY scale factor of the game object instance without affecting Z.
Use this function when you want to scale in 2D while leaving the Z scale unchanged.
Parameters:
scale | uniform or vector scale where x/y are applied; z is preserved |
|---|---|
id | optional id of the game object instance to set the scale for, defaults to the caller |
staticupdateWorldTransform(?id:Null<HashOrStringOrUrl>):Void
- Updates the world transform for a game object instance and its hierarchy up to the root.
This function forces a recalculation of the world transform of the specified object (including parents up to the root) which can be useful after multiple local transform changes when an immediate world transform update is needed.
Parameters:
id | optional id of the game object instance to update, by default the instance of the calling script |
|---|