Called when the holder becomes the hand for a player.
Called when a card is flipped on the holder by a player. The call happens immediately when the player initiates the flip and the animation starts.
Called when a card is rotated on the holder by a player. The call happens immediately when the player initiates the rotation and the animation starts.
Called when the object is created (from the object library, loading a game, copy & paste, dragging from an infinite container or stack...)
Called when a custom action defined through addCustomAction is executed.
Called when the object is destroyed
Called when the flip/upright action is executed on the object. This can happen while held or when a user presses the flip/upright button while the object is selected or highlighted. The event is triggered immediately when the action starts, so the object will not have flipped yet.
Called when the object is picked up
Called when the object is hit by another object or hits another object. Gets called for both objects involved in a collision. Only called for collisions that cause an impact sound to be played.
Called when a card is dropped onto the holder by a player
Called when the object comes to rest. For ground objects or when the session is set to locked physics, the object has been locked right before this event is triggered.
Called when a player executes a number action on the object (by highlighting or selecting it and pressing number keys). Will be called even if the object has a defined behavior for number actions (like dice or multistate objects), after any object defined behavior.
Called a player executes the primary action on an object by pressing the respective button (default mapping "R"). Will be called even if the object has a defined behavior for primary actions (like dice or multistate objects), after any object defined primary action.
Called when the object is released (but not reset). When the object is snapped, onSnapped or onSnappedToGrid are called in addition.
Called when a card is dragged from the holder by a player
Called when the object is reset to its position before being picked up.
Called a player executes the secondary action on an object by pressing the respective button (default mapping "Ctrl+R"). Will be called even if the object has a defined behavior for primary actions (like card stacks or multistate objects), after any object defined primary action.
Called when the object is snapped to a snap point on releasing. Not called when snapping to the global grid, in that case onSnappedToGrid is called instead.
Called when another object is snapped to a snap point on this object. This event is triggered for the object with the target snap point, see GameObject.onSnapped for an event on the object that snaps.
Called on releasing an object when the object is snapped to the global grid or because of the "Always Snap" setting in the session options.
Called every tick.
Add a custom action that appears in the context menu of the object.
The name for the action in the context menu
The tooltip text to show for the custom action
An identifier passed to the onCustomAction event if you don't want to use the action name to identify what action is executed. If empty, the action name is used as identifier.
Add a drawn line to the object. Lines are geometry and can increase the size of the object returned by getSize and getExtent. Returns whether the line was added successfully. It can't be added if no table exists, if the DrawingLine is invalid, or if there are already too many lines drawn on the table and the new line would go beyond the limit.
Attach a new UI element object to this object.
The UI element to attach
Apply a torque to the object. Works as an instant change of angular velocity.
The axis of rotation and magnitude of the impulse to apply in kg*cm^2/s.
If false (default), ignore the mass of the object and apply the force directly as change of angular velocity in cm^2/s.
Apply a force to the object. Works like a "thruster" and should be called every tick for the duration of the force.
The direction and magnitude of the force to apply in kg*cm/s^2.
If false (default), ignore the mass of the object and apply the force directly as change of acceleration in cm/s^2.
Apply a force to the object. Works like a "thruster" and should be called every tick for the duration of the force.
The direction and magnitude of the force to apply in kg*cm\s^2.
The position where to apply the force, relative to the object origin. If this is not equal to the center of mass, the force will create angular acceleration.
Apply an impulse to the object. Works as an instant change of velocity.
The direction and magnitude of the impulse to apply in kg*cm/s.
If false (default), ignore the mass of the object and apply the impulse directly as change of velocity in cm/s.
Apply an impulse to the object. Works as an instant change of velocity.
The direction and magnitude of the impulse to apply in kg*cm/s
The position where to apply the impulse, relative to the object origin. If this is not equal to the center of mass, the force will create angular velocity.
Apply a torque to the object. Works like a "thruster" and should be called every tick for the duration of the torque.
The axis of rotation and magnitude of the torque to apply in kg*cm^2/s^2.
If false (default), ignore the mass of the object and apply the force directly as change of angular acceleration in cm^2/s^2.
Return whether lights on this object are switched on
The UI element to attach
Create and return a new switcher with this object as the first (and active) state
The other objects to include in the switcher. At least one element is needed because switchers are only valid with at least two objects.
Destroy the object
Flips a card on the holder (back to front). Does nothing if the card is not in the holder.
The card to flip
Flip the object or rotate it to its default orientation, depending on the object. Uses animation and physics. Calling this does the same thing as a player pressing the flip/upright key for highlighted or selected objects. Cards in holders are also flipped, but held objects are not affected.
Immediately freeze the object and set its type to ground if it is currently not a ground object.
Return an array with all snap points of the object
Return the object's angular (rotational) velocity in degrees/s
Return the object's bounciness value
Return contained cards. Manipulating the array (e.g. removing or adding objects) does not change the contents of the holder!
Return the object's center of mass
Returned the container that this object is in. Return undefined if the object is not in a container.
Return the object's density value
Return the object's description
Return all drawing lines on the object.
Get the object extent: half-size of an axis-aligned bounding box encompassing the object. Adding this vector to the position returned by getExtentCenter gives a corner of the bounding box.
If true, return the extent of an axis-aligned bounding box around the object at its current rotation. If false, return for the default rotation.
Determines whether visible geometry is included in the extent. If false, only colliders are used when determining the extent.
Get the center of the object extent: an axis-aligned bounding box encompassing the object. This will often be the same position as returned by getPosition, but will differ for objects with their physical center not at their volume center.
If true, return the extent of an axis-aligned bounding box around the object at its current rotation. If false, return for the default rotation.
Return the object's friction value
Return the object's group id. Objects with the same group id are always picked up together. Returns -1 if the object is not part of a group.
Return how hidden cards are shown on the card holder, as defined by HiddenCardsType
Return the object's unique id
Return the object's linear velocity in cm/s
Return the object's mass in kg
Return the object's metallic value.
Return the object's user visible name
Return number of cards in the holder
Get the object's type. Possible values are defined in ObjectType.
Return if only the owner is allowed to take cards from the holder
Return the player slot that owns the object. Returns undefined for objects without owner.
Return the player slot that owns the object. Returns -1 for holders without owner.
Return the id of the package that the object's template belongs to
Return the name of the package that the object's template belongs to
Return the object's position
Return the object's primary color
Return the object's rotation
Return the object's roughness value. Lower roughness makes the object more shiny.
Return data that was stored using setSavedData or loaded from a saved state.
Return the object's scale
Return the filename of the object's script. Returns an empty string if no script is set for the object.
Return the package id of the object's script. Returns an empty string if no script is set for the object.
Return the object's secondary color
Return a snap point of the object
Index of the snap point
Return the snap point that the object is snapped to (or more precisely, the snap point that the object would snap to if it was snapped now). Return undefined if the object is not snapped to any points. Objects are not bound to snap points when they are snapped, only their position is adjusted. Therefore, this method is not guaranteed to work correctly. It uses the same mechanism that regular snapping uses to determine where an object should snap. This could fail for snap points that are high above a surface: the object may have fallen or snapped too far below the snap point.
Return surface type. Only affects sound effects when colliding with other objects.
Get the switcher that contains this object. Returns undefined if the object is not part of a switcher
Return the current list of tags for the object.
Return the object's template id
Return the metadata of the object's template (set in the editor). Can contain JSON encoded information.
Return the name of the object's template
Does the card holder hold the given card?
Card to check
Insert a card into the holder. Return whether the card was inserted successfully
Card to insert
The index at which the new objects will be inserted. By default, it will be inserted at start (index 0)
Returns if the face of a card on the is visible. Always returns false if the card is not on the holder.
The card to check
Returns if a card on the holder is rotated to be upside down. Always returns false if the card is not on the holder.
The card to check
Return if the object is currently held by a player
Return whether the object is currently simulating physics. If false, the object is stuck in place and won't move when hit by other objects. This can happen with stationary ground mode objects or with locked physics sessions.
Return whether the object is allowed to snap
Return whether the object is valid. An object becomes invalid after it has been destroyed
Move a card on the holder to a new position
The card to move
New index for the card
Ensure that no player is holding this object. If any player is currently holding the object, it will fall down. Some GameObject methods (like setting position or applying physical force) don't have an effect or do not work properly while a player is holding the object.
Remove a card from the holder. The removed card does not change its position.
The index of the card to remove
Remove a custom action by identifier or name.
The identifier or name of the action to remove
Remove the drawn line at the given index from the object
Remove a drawn line from the object.
Remove attached UI element at the given index.
The index of the UI element to remove
Remove an attached UI element. Does not have any effect if the passed UI element is not attached to the object.
Rotate a card on the holder (upside down). Does nothing if the card is not in the holder.
The card to rotate
Set the object's angular (rotational) velocity in degrees/second. Note that setting velocity directly can lead make the physics simulation unstable, you should prefer to apply impulse, torque, or force to the object.
The new angular velocity
Set the object's bounciness value
The new bounciness value, from 0 to 1
Set the object's density value
The new density value
Set the object's description
The new object description. Maximum length is 2000 characters. You can use the same BBCode tags as in the in-game notes or the RichText widget.
Set the object's friction value
The new friction value, from 0 to 1
Set the object's group id. Objects with the same group id are always picked up together.
The new group id. Set to -1 to remove the object from all groups.
Set how hidden cards are shown on the card holder, as defined by HiddenCardsType. Setting the type to front effectively disables hiding for this holder.
Set the object's unique id. Returns whether the id was changed successfully. Fails if the id is already used by another object.
Set the object's linear velocity in cm/second. Note that setting velocity directly can lead make the physics simulation unstable, you should prefer to apply impulse or force to the object.
The new velocity
Set the object's metallic value
The new metallic value, from 0 to 1
Set the object's user visible name
The new name
Set the object's type. Available options are defined in ObjectType.
The new object type
Set if only the owner is allowed to take cards from the holder
Set the player slot that owns the object. Set to -1 to remove owner.
The new owning player slot
Set the object's position. Optionally show an animation of the object flying toward the new location. The animation is only visual, the physical location of the object is changed instantly. Does not have an effect if a player is currently holding the object.
The new position
If larger than 0, show animation. A value of 1 gives a reasonable, quick animation. Value range clamped to [0.1, 5.0]. Default: 0
Set the object's primary color
The new primary color
Set the object's rotation. Optionally show an animation of the object rotating toward the new orientation. The animation is only visual, the physical rotation of the object is changed instantly. Does not have an effect if a player is currently holding the object.
The new rotation
If larger than 0, show animation. A value of 1 gives a reasonable, quick animation. Value range clamped to [0.1, 5.0]. Default: 0
Set the object's roughness value. Lower roughness makes the object more shiny.
The new roughness value, from 0 to 1
Set the data that will be stored in save game states. The data is available using getSavedData when the object
script is run after loading a save state. Try to keep this data small and don't change it frequently, it needs to
be sent over the network to all clients. A similar method exists for global saved data: GameWorld.setSavedData.
If you want to use custom data that is not a string, you can encode it to JSON using JSON.stringify()
, and then
decode what you get from getSavedData using JSON.parse()
.
Data to store, maximum length 1023 characters
Set the object's scale instantly
The new scale
Set the object's script. The script will be executed immediately.
The filename of the script. Pass an empty string to remove the current script.
The id of the package that contains the script file (in the Scripts folder). Can usually be empty when used from scripts to use the same package that contains the script file, but you need to explicitly pass refPackageId for the current package or a package id when you use it in a callback. You can find package ids in the manifest.json file in package folders. Usually you won't use this parameter, unless you have a specific reason to set a script from a different package than where the calling script is located.
Set the object's secondary color
The new secondary color
Set whether the object is allowed to snap
Whether snapping will be allowed
Set surface type. Only affects sound effects when colliding with other objects.
Set the list of tags for the object.
Replace an attached UI element. Will not do anything if called with an index that doesn't have a UI element.
Snap the object as if it was dropped at its current position. Does nothing if no snap point is in range below the object. Snapping in this way does not trigger the onSnapped callback. Returns the snapped point if the object was snapped. Optionally show an animation of the object rotating toward the new orientation. The animation is only visual, the physical rotation of the object is changed instantly. Does not have an effect if a player is currently holding the object.
If larger than 0, show animation. A value of 1 gives a reasonable, quick animation. Value range clamped to [0.1, 5.0]. Default: 0
Snap the object to the ground below it.
Switch lights on this object on or off
Return a Json string representing the object. Can be used to spawn copies.
Immediately freeze the object and set its type to ground if it is currently not a ground object. Set its type to regular if it is currently a ground object. If you want to completely lock an object and not allow players to interact with it, use setObjectType with ObjectType.NonInteractive instead.
Update an attached UI element. Will not do anything if called with a UI element that is not attached to
the object. You need to call this method after modifying values in a UIElement
. Does not work if
you change the UIElement.widget property, you have to use setUI in this case.
Used when executing an object script to determine why it was executed. Possible return values:
"Create" - The object was newly created, for example from the object library or through copy and paste
"ScriptReload" - The script was reloaded, for example because it was set on the object for the first time, or because the scripting environment was reset
"StateLoad" - A game state that contained the object was loaded
A card holder