Entity

An Entity is an object that exists in your 3D world.

Function Description
addChild(entity)

Makes the specified entity a child of the current Entity.

camera()

Returns the Camera within the world where the Entity exists. This could be a UI camera or a Scene camera.

children() Returns the array of child Entities that this Entity has.
color()

Returns the color of the Entity’s 3D Model in RGB (Red, Green, Blue) format. The minimum value is 0 and the maximum is 255. For example, {r:0, g:0, b:0} is black and {r:255, g:255, b:255} is white.
Note, if the Entity has multiple 3D Model nodes, this function will return the color of the first one that was created.

component(name)

Searches for the component with the specified name in the current Entity and returns it if it’s found. Otherwise, returns null. Note that if you have multiple components with the same name, component() will simply return the first one it finds. It’s advised to give your components unique names to avoid bugs.

createComponent(type, name)

Creates a new component (Node) and activates it. Currently these components can be created programmatically: Animation, 3D Model, and If Collide.
When creating a 3D Model node this way, a mesh must be set before functions like setPosition() can be used on it.
Please see setMesh() for more notes on recommended usage.

isVisible()

Returns if the Entity is visible.

levelName()

Returns the name of the level that the Entity exists in. This refers to the Scene Selector “level” names at the bottom of the screen in a 3D World.

linkedEntities()

Returns the array of Entities linked to this one with the Linker.

localAABB()

Returns the local “axis-aligned bounding box” for the Entity. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). Useful for checking the size of your Entity and for ray casting.

name()

Returns the Asset name assigned to Entity.

parent()
physics()

Returns the Physics Component of the Entity. null is returned if physics is not enabled for this Entity (the checkbox on the Start node).

position()

Returns the Entity’s position relative to its parent. If the Entity has no parent, the result of this function will be no different than worldPosition.

remove()

Remove the Entity from the Scene.

rotation()
rotationQuat()
scale()
setAnimate(value)

Enables/disables animation on the Entity. In this case, “animation” is referring to the position, rotation, and scale animations in the editor.

setColor(r, g, b, a)

Sets the color of every 3D model within the Entity. Uses RGB (Red, Green, Blue) format. The minimum value is 0 and the maximum is 255. For example, {r:0, g:0, b:0} is black and {r:255, g:255, b:255} is white. Alpha is an optional parameter and sets the opacity of the 3D Model.

setOpacity(value)

Sets opacity of every 3D model and animation in the Entity.

setPosition(x, y, z)

Sets the new position relative to the Entity’s parent. If the Entity has no parent, this sets the world position of the Entity.

setRotation(x, y, z)

Sets the rotation value of the Entity, in degrees. This will affect the rotation of every 3D Model within the Entity.

setRotationQuat(value)

Sets rotation value in Quaternion.

setScale(x, y, z)

Sets the scale of the Entity. This will affect the scale of every 3D Model within the Entity.

setTexture(name)

Applies a new texture to all 3D Models within the Entity. The texture should be present in Sprite Editor.

setVisible(value)

Sets the visibility of the Entity; true if the Entity is visible, false if not.

transform()
transformedAABB()

Returns the relative “axis-aligned bounding box” for the Entity. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). Useful for checking the size of your Entity relative to its parent, and for ray casting.

transformedOBB()

Returns the “oriented bounding box” for the Entity relative to its parent. OBB is more precise but more performance-heavy than AABB.

worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the Entity. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). Useful for checking the size of your Entity and for ray casting.

worldOBB()

Returns the “oriented bounding box” for the Entity. OBB is more precise but more performance-heavy than AABB.

worldPosition()

Returns the entity’s position coordinates in the world (absolute position).


addChild(entity)

Makes the specified entity a child of the current Entity.

Entity entity the Entity object that will become the child of the Entity you’re calling the method on.

let ent = this.scene().create('Cone');
this.entity().addChild(ent);

↑ Back to top


camera()

Returns the Camera within the world where the Entity exists. This could be a UI camera or a Scene camera.

Returns

Camera The Camera within the world where the Entity exists.

↑ Back to top


children()

Returns the array of child Entites that this Entity has.

Returns

array The array of children Entities that this Entity has.

let children = this.entity().children();
// reset position of all children
for (i = 0; i <children.length; i++){
  children[i].setPosition(0, 0, 0);
}

↑ Back to top


color()

Returns the color of the Entity’s 3D Model in RGB (Red, Green, Blue) format. The minimum value is 0 and the maximum is 255. For example, {r:0, g:0, b:0} is black and {r:255, g:255, b:255} is white.
Note, if the Entity has multiple 3D Model nodes, this function will return the color of the first one that was created.

Returns

Object {r, g, b} color pigment of the Entity’s 3D Model.

let ent = this.scene().create("Cube");
log(ent.color().r); // result: the red component of the cube's color.

↑ Back to top


component(name)

Searches for the component with the specified name in the current Entity and returns it if it’s found. Otherwise, returns null. Note that if you have multiple components with the same name, component() will simply return the first one it finds. It’s advised to give your components unique names to avoid bugs.

Parameters

string name – The name of the component to search for.

Returns

Component The Component object found with the given name.

let collide = this.entity().component('If Collide');
if(collide){ // check that collide is not null
  let obj = collide.collisionObject();
}

↑ Back to top


createComponent(type, name)

Creates a new component (Node) and activates it. Currently these components can be created programmatically: Animation, 3D Model, and If Collide.
When creating a 3D Model node this way, a mesh must be set before functions like setPosition() can be used on it.
Please see setMesh() for more notes on recommended usage.

Parameters

string type – Possible inputs: “Animation”, “3D Model”, or “If Collide”
string name – The name of the new component.

Returns

Component the newly created component (Animation, 3D Model, or If Collide).

let modelComp = this.entity().createComponent("3D Model", "myModel");
modelComp.setMesh(this.attribute("meshAttribute"));
modelComp.setPosition(0, 10, 0); // now that a mesh is set, any Model 3D functions can be used

let animComp = this.entity().createComponent("Animation", "myAnim");
animComp.setAnimation(this.attribute("bounceAnimation"));

let collideComp = this.entity().createComponent("If Collide", "myCollide");
collideComp.setActive(true);

↑ Back to top


isVisible()

Returns if the Entity is visible.

Returns

boolean true if the Entity is visible, false if the Entity is not.

↑ Back to top


levelName()

Returns the name of the level that the Entity exists in. This refers to the Scene Selector “level” names at the bottom of the screen in a 3D World.

Returns

string The name of the level that the Entity exists in.

// remove all cubes from level 5
let cubes = this.scene().find("Cube");
for (int i=0; i<cubes.length; i++){
  if (cubes[i].levelName() == "5"){
    cubes[i].remove();
  }
}

↑ Back to top


linkedEntities()

Returns the array of Entities linked to this one with the Linker.

Returns

Array of Entities linked to this one.

↑ Back to top


localAABB()

Returns the local “axis-aligned bounding box” for the Entity. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). Useful for checking the size of your Entity and for ray casting.

Returns

AABB AABB object containing relative AABB data

↑ Back to top


name()

Returns the Asset name assigned to Entity.

Returns

string name of the Asset assigned to the Entity.

↑ Back to top


parent()

Returns

Entity the parent Entity of this Entity, or null if no parent exists.

let parent = this.entity().parent();

↑ Back to top


physics()

Returns the Physics Component of the Entity. null is returned if physics is not enabled for this Entity (the checkbox on the Start node).

Returns

Physics Component the Physics Component of the entity

let physics = this.entity().physics();
if(physics){ // check that physics is not null
  physics.setLinearVelocity(0, 20, 0);
}

↑ Back to top


position()

Returns the Entity’s position relative to its parent. If the Entity has no parent, the result of this function will be no different than worldPosition.

Returns

Vec3 {x, y, z} relative coordinates of the Entity.

let pos = this.entity().position();
log('X position = ' + pos.x);

↑ Back to top


remove()

Remove the Entity from the Scene.

//Remove an entity if it goes further than 10 units on the X axis.
let pos = this.entity().position()
if(pos.x > 10){
  this.entity().remove();
}

↑ Back to top


rotation()

Returns

Vec3 The {x, y, z} rotation value of the Entity, in degrees.

↑ Back to top


rotationQuat()

Returns

Quaternion The rotation value in Quaternion.

↑ Back to top


scale()

Returns

Vec3 The {x, y, z} scale value of the Entity.

↑ Back to top


setAnimate(value)

Enables/disables animation on the Entity. In this case, “animation” is referring to the position, rotation, and scale animations in the editor.

Parameters

boolean value – True if enabled, false if disabled.

↑ Back to top


setColor(r, g, b, a)

Sets the color of every 3D model within the Entity. Uses RGB (Red, Green, Blue) format. The minimum value is 0 and the maximum is 255. For example, {r:0, g:0, b:0} is black and {r:255, g:255, b:255} is white. Alpha is an optional parameter and sets the opacity of the 3D Model.

Parameters

number r – the red component of the color
number g – the green component of the color
number b – the blue component of the color
number a – (Optional) The alpha component of the color. Range: 0-255

↑ Back to top


setOpacity(value)

Sets opacity of every 3D model and animation in the Entity.

Parameters

number value – Range: 0-1. The lower the value, the less opaque the button becomes.

↑ Back to top


setPosition(x, y, z)

Sets the new position relative to the Entity’s parent. If the Entity has no parent, this sets the world position of the Entity.

Parameters

number x – X coordinate in 3D space
number y – Y coordinate in 3D space
number z – Z coordinate in 3D space

↑ Back to top


setRotation(x, y, z)

Sets the rotation value of the Entity, in degrees. This will affect the rotation of every 3D Model within the Entity.

Parameters

number x – the X rotation of the Entity
number y – the Y rotation of the Entity
number z – the Z rotation of the Entity

↑ Back to top


setRotationQuat(value)

Sets rotation value in Quaternion.

Parameters

Quaternion value – The Quaternion rotation value to be set

↑ Back to top


setScale(x, y, z)

Sets the scale of the Entity. This will affect the scale of every 3D Model within the Entity.

Parameters

number x – The scale of the Entity on the x axis
number y – The scale of the Entity on the y axis
number z – The scale of the Entity on the z axis

↑ Back to top


setTexture(name)

Applies a new texture to all 3D Models within the Entity. The texture should be present in Sprite Editor.

Parameters

string name – The name of the texture to be applied.

if(health <= 0.5){
  this.entity().setTexture('Damaged Texture');
}

↑ Back to top


setVisible(value)

Sets the visibility of the Entity; true if the Entity is visible, false if not.

Parameters

boolean value – the visibility of the Entity.

↑ Back to top


transform()

Returns

Mat4 the Mat4 transformation matrix of the Entity.

↑ Back to top


transformedAABB()

Returns the relative “axis-aligned bounding box” for the Entity. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). Useful for checking the size of your Entity relative to its parent, and for ray casting.

Returns

AABB AABB object containing relative AABB data

↑ Back to top


transformedOBB()

Returns the “oriented bounding box” for the Entity relative to its parent. OBB is more precise but more performance-heavy than AABB.

Returns

OBB OBB object containing relative OBB data

↑ Back to top


worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the Entity. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). Useful for checking the size of your Entity and for ray casting.

Returns

AABB AABB object containing world AABB data

↑ Back to top


worldOBB()

Returns the “oriented bounding box” for the Entity. OBB is more precise but more performance-heavy than AABB.

Returns

OBB OBB object containing OBB data

↑ Back to top


worldPosition()

Returns the entity’s position coordinates in the world (absolute position).

Returns

Vec3 the {x, y, z} world coordinates of the Entity

let pos = this.worldPosition();
log('X World Position = ' + pos.x);

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.