ATTRIBUTE( NAME )
Returns the value of an attribute.
name – Name of the attribute.
function init(){
let speed = this.attribute('Speed');
}
Returns the value of an attribute.
name – Name of the attribute.
function init(){
let speed = this.attribute('Speed');
}
This kind of Animation can be created from an Animation script attribute. It’s useful because you can instantiate many copies of the same animation attribute using code. An Animation is two-dimensional. Here’s an example of creating an Animation from an attribute.
let attribute = this.attribute('Flame'); let anim = new Animation(attribute, this);
| Function | Description |
|---|---|
| play() |
Starts playing the animation from its beginning. |
| position() |
Returns the Animation’s position relative to its Entity. |
| rotation() |
Returns the rotation of the Animation. in degrees. |
| scale() |
Returns the scale of the Animation. |
| setFrame(value) |
Sets the Animation to a specific frame. |
| setOpacity(value) |
Sets the opacity of the Animation. |
| setPosition(x, y, z) |
Sets the position of the Animation. |
| setRotation(value) |
Sets the rotation of the Animation, in degrees. |
| setScale(x, y, z) |
Sets the scale of the Animation. |
| setVisible(value) |
Sets the visibility of the Animation. |
Starts playing the animation from its beginning.
Returns the Animation’s position relative to its Entity.
Vec3 {x, y} relative coordinates of the Animation.
Returns the rotation of the Animation. in degrees.
number the rotation of the Animation, in degrees.
Returns the scale of the Animation.
Vec2 {x, y} scale of the Animation.
Sets the Animation to a specific frame.
number value – the frame the Animation will be set to.
Sets the opacity of the Animation.
number value – new opacity value, range: 0-255
Sets the position of the Animation.
number x – new x-axis position of the Animation
number y – new y-axis position of the Animation
number z – (optional) z-axis position of the Animation
Sets the rotation of the Animation, in degrees.
number value – new rotation of the Animation, in degrees
Sets the scale of the Animation.
number x – x-axis scale of the Animation
number y – y-axis scale of the Animation
number z – (optional) z-axis scale of the Animation
Sets the visibility of the Animation.
boolean value – true for visible, false for not visible.
These functions help you control advertisements shown in your game. Check out this page of the manual to learn how to monetize your game with advertisements. Note that you won’t see any ad banners or videos in the Preview window of BuildBox.
| Static Function | Description |
|---|---|
| hideBanner() |
Hides a banner ad if it is visible. |
| isRemoveAdsPurchased() |
Returns true if the user has paid to remove ads, and false if not. |
| isRewardedVideoAvailable() |
Returns true if a rewarded video is available to show, and false if not. |
| showBanner() |
Shows a banner ad. |
| showInterstitial() |
Shows an interstitial (video advertisement) to the user. |
| showRewardedVideo(callback) |
Shows Rewarded Video to the user. callback will be triggered when the video ends. |
Hides a banner ad if it is visible.
Returns true if the user has paid to remove ads, and false if not. Check this page of the manual to learn how to allow the user to pay to remove ads.
boolean true if the user has paid to remove ads, false if not
Returns true if a rewarded video is available to show, and false if not.
boolean true if a rewarded video is available to show, false if not
Shows a banner ad.
Shows an interstitial (video advertisement) to the user.
Shows Rewarded Video to the user. callback will be triggered when the video ends.
let callback = function(){ //when this fires, the rewarded video is complete. Give reward to player here } callback = callback.bind(this); Ads.showRewardedVideo(callback);
Keyframe Animaion Models are used with Sub Scenes to control FBX assets. Check the manual page for more information.
| Function | Description |
|---|---|
| duration() |
Returns the duration of the Keyframe Animation Model. |
| name() |
Returns the name of the Keyframe Animation Model. |
Returns the duration of the Keyframe Animation Model.
number the duration of the animation
Returns the name of the Keyframe Animation Model.
string the name of the animation
| Function | Description |
|---|---|
| affectedAsset() |
Returns the affected asset of the If Collide node. If the entity collides with another entity of the affected asset type, the If Collide node will trigger its “Collide” output signal. |
| collisionEntity() |
Returns the last Entity that was collided with. Returns Null if there has never been a collision. |
| mesh() |
Returns the collision shape mesh, if the If Collide node has one. Returns null if not. |
| parentEntity() |
Returns the entity that the If Collide node belongs to. |
| rebuildShape() |
This method rebuilds the collision shape of the If Collide node. You must call this when you want a new shape position, rotation, scale, and/or type applied. Warning: this is a costly operation. |
| setActive(value) |
Enables/disables the If Collide node. |
| setAffectedAsset(value) |
Changes the affected asset of the If Collide node. |
| setMesh(meshModel) |
Sets the mesh of the collision shape using a MeshModel script attribute. See attribute() in the Script section for more information. |
| setMesh(value) |
Sets the mesh of the collision shape using a string name. It is recommended to use a MeshModel script attribute instead, to avoid issues with meshes with the same name. |
| setShapePosition(x, y, z) |
Sets the position of the collision shape. Note that you’ll have to call rebuildShape() after using this method for the change to take effect. |
| setShapeRotation |
Sets the rotation of the collision shape. Note that you’ll have to call rebuildShape() after using this method for the change to take effect. |
| setShapeScale |
Sets the scale of the collision shape. Note that you’ll have to call rebuildShape() after using this method for the change to take effect. |
| setShapeType(type) |
Sets the collision shape type. Note that you’ll have to call rebuildShape() after using this method for the change to take effect. |
| shapePosition() |
Returns the position of the collision shape. |
| shapeRotation() |
Returns the rotation of the collision shape. |
| shapeScale() |
Returns the scale of the collision shape. |
| shapeType() |
Returns the type of the collision shape. |
Returns the affected asset of the If Collide node. If the entity collides with another entity of the affected asset type, the If Collide node will trigger its “Collide” output signal.
string the affected asset of the If Collide node: kNone, kCharacter, kEnemy, kPlatform, kCoin
Returns the last Entity that was collided with. Returns Null if there has never been a collision.
Entity the last Entity that was collided with
Returns the collision shape mesh, if the If Collide node has one. Returns null if not.
Mesh Model the collision shape mesh
Returns the entity that the If Collide node belongs to.
Entity the If Collide’s parent Entity
This method rebuilds the collision shape of the If Collide node. You must call this when you want a new shape position, rotation, scale, and/or type applied. Warning: this is a costly operation.
let col = this.entity().component("If Collide"); col.setShapePosition(0, 1, 0); col.rebuildShape(); // call rebuildShape() for my position change to take effect.
Enables/disables the If Collide node.
boolean value – true to enable the node, false to disable it
Changes the affected asset of the If Collide node.
string value – the new affected asset. Possible values: kNone, kCharacter, kEnemy, kPlatform, kCoin
Sets the mesh of the collision shape using a MeshModel script attribute. See attribute() in the Script section for more information.
MeshModel mesh – the new mesh of the collision shape
Sets the mesh of the collision shape using a string name. It is recommended to use a MeshModel script attribute instead, to avoid issues with meshes with the same name.
string mesh – the name of the new mesh
Sets the position of the collision shape. Note that you’ll have to call rebuildShape() after using this method for the change to take effect.
number x – the x coordinate position
number y – the y coordinate position
number z – the z coordinate position
Sets the rotation of the collision shape. Note that you’ll have to call rebuildShape() after using this method for the change to take effect.
number x – the x coordinate rotation
number y – the y coordinate rotation
number z – the z coordinate rotation
Sets the scale of the collision shape. Note that you’ll have to call rebuildShape() after using this method for the change to take effect.
number x – the x coordinate scale
number y – the y coordinate scale
number z – the z coordinate scale
Sets the collision shape type. Note that you’ll have to call rebuildShape() after using this method for the change to take effect.
It is recommended to use “kHullShape” over “kMeshShape” as it is less memory intensive.
string type – The new collision shape type. Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”
Returns the position of the collision shape.
Vec3 the {x, y, z} position coordinates of the collision shape
Returns the rotation of the collision shape.
Vec3 the {x, y, z} rotation coordinates of the collision shape
Returns the scale of the collision shape.
Vec3 the {x, y, z} scale coordinates of the collision shape
Returns the type of the collision shape.
string the collision shape type. Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”
An Entity is an object that exists in your 2D/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 RGBA (Red, Green, Blue, Alpha) format. |
| component(name) | Searches for the component with the specified name in the current Entity and returns it if it’s found. Otherwise, returns null. |
| components() | Returns an array containing all the entity’s components (also known as nodes). |
| 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. |
| forceInit() | Forces a newly created Entity to initialize right away. |
| globalDepth() | Returns the depth of the Entity in a 2D World. |
| id() | Returns the Entity’s unique id. Each instance of the Entity in the Scene will have a different id. |
| isCharacter() | Returns if the Entity is a Character (vs an Object). |
| isRemoved() | Returns if the Entity has been removed or not. |
| isVisible() | Returns if the Entity is visible. |
| level() | Returns the LevelSector that the Entity exists in. This refers to the Scene Selector “level” at the bottom of the screen in a 2D/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() | Returns the Entity’s parent, or null if it doesn’t have one. |
| 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() | Removes the Entity from the Scene. |
| removeComponent(component) | Removes the given component on the next frame. |
| rotation() | Returns the rotation of the Entity (relative to its parent) in degrees (Vec3). |
| rotationQuat() | Returns the rotation of the Entity (relative to its parent) in Quaternion. |
| setParent(parent) | Sets the Entity as a child of the given parent entity or scene, removing it from its current parent. |
| scale() | Returns the scale of the Entity in Vec3. |
| setAnimate(value) | Enables/disables animation on the Entity. In this case, “animation” is referring to the position, rotation, and scale animations in the editor. |
| setCastShadows(value) | Enables/disables shadow casting of all 3D Models within the Entity at once. |
| 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. |
| setGlobalDepth(value) | Set the depth of the Entity in a 2D World. |
| setOpacity(value) | Sets opacity of every 3D model and animation in the Entity. |
| setPosition(x, y, z) | Sets the position of the Entity relative to the Entity’s parent. If the Entity has no parent, this sets the world position of the Entity. |
| setWorldPosition(x, y, z) | Sets the world position of the Entity, not relative to any parent. |
| setReceiveShadows(value) | Enables/disables shadow receiving of all 3D Models within the Entity at once. |
| 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() | Returns the transformation matrix of the Entity. |
| 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). |
| worldRotation() | Returns the entity’s rotation in degrees (not relative to its parent). |
| worldRotationQuat() | Returns the entity’s rotation in Quaternion (not relative to its parent). |
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);
Returns the Camera within the world where the Entity exists. This could be a UI camera or a Scene camera.
Camera The Camera within the world where the Entity exists.
Returns the array of child Entites that this Entity has.
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); }
Returns the color of the Entity’s 3D Model in RGBA (Red, Green, Blue, Alpha) format. The minimum value is 0 and the maximum is 255. For example, {r:0, g:0, b:0, a:1} is black and {r:255, g:255, b:255, a:1} is white.
Note, if the Entity has multiple 3D Model nodes, this function will return the color of the first one that was created.
Object {r, g, b, a} 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.
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.
string name – The name of the component to search for.
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(); }
Returns an array containing all the components in the Entity’s mind map.
Array – array of components
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.
string type – Possible inputs: “Animation”, “3D Model”, or “If Collide”
string name – The name of the new component.
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);
Normally Entities are initialized (which includes running their scripts’ init() functions) on the next frame. Calling this function on a newly created Entity will initialize right away instead. This can be useful if you have variables or functions being created in the Entity’s init() function that will need to be accessed immediately by the Entity creating it. Check out the simple example below.
// first entity function start(){ let ent = this.scene().create('Enemy'); ent.forceInit(); // without forceInit(), this call would fail because ent isn't initialized yet: ent.testFunction("Hello World"); } // spawned entity function init(){ this.entity().testFunction = (string) => log(string); // logs the string passed to it }
Returns the global depth of the Entity. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.
number – The global depth of the Entity
Returns the Entity’s unique id. Each instance of the Entity in the Scene will have a different id, including Entities that are made using this.scene().create().
number – the Entity’s id
Returns if the Entity is a Character (vs an Object).
boolean true if the Entity is a Character, false if the Entity is not.
Returns if the Entity has been removed or not.
boolean true if the Entity is has been removed, false if not.
Returns if the Entity is visible.
boolean true if the Entity is visible, false if the Entity is not.
Returns the LevelSector that the Entity exists in. This refers to the Scene Selector “level” at the bottom of the screen in a 2D/3D World.
LevelSector The LevelSector 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].level().name() == "5"){ cubes[i].remove(); } }
Returns the array of Entities linked to this one with the Linker.
Array of Entities linked to this one.
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.
AABB AABB object containing relative AABB data
Returns the Asset name assigned to Entity.
string name of the Asset assigned to the Entity.
Returns the Entity’s parent, or null if it doesn’t have one.
Entity the parent Entity of this Entity, or null if no parent exists.
let parent = this.entity().parent();
Returns the Physics Component of the Entity. null is returned if physics is not enabled for this Entity (the checkbox on the Start node).
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); }
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.
Vec3 {x, y, z} relative coordinates of the Entity.
let pos = this.entity().position();
log('X position = ' + pos.x);
Removes the Entity from the Scene. Note that if you try to access this Entity after it has been removed, you’ll get a null reference error. To protect from this, check this.entity().isRemoved() first.
//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(); }
Removes the given component on the next frame. The component object is required as a parameter; this can be found by name with this.entity().component(name) for example.
Component component The component to remove
Returns the rotation of the Entity in degrees (Vec3) relative to its parent.
Vec3 The {x, y, z} rotation value of the Entity, in degrees.
Returns the rotation of the Entity in Quaternion relative to its parent.
Quaternion The rotation value in Quaternion.
Sets the Entity as a child of the given parent entity or scene, removing it from its current parent. If passed null, the Entity will be parented to the current scene.
Entity/LevelSector parent The new parent of the Entity
Returns the scale of the Entity in Vec3.
Vec3 The {x, y, z} scale value of the Entity.
Enables/disables animation on the Entity. In this case, “animation” is referring to the position, rotation, and scale animations in the editor.
boolean value – True if enabled, false if disabled.
Enables/disables shadow casting of all 3D Models within the Entity at once.
boolean value – True if enabled, false if disabled.
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.
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
Sets the global depth of the Entity. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.
number value – The global depth of the Entity
Sets opacity of every 3D model and animation in the Entity.
number value – Range: 0-1. The lower the value, the less opaque the Entity becomes.
Sets the position of the Entity relative to the Entity’s parent. If the Entity has no parent, this sets the world position of the Entity.
number x – X coordinate in 3D space
number y – Y coordinate in 3D space
number z – Z coordinate in 3D space
Sets the world position of the Entity, not relative to any parent.
number x – X coordinate in 3D space
number y – Y coordinate in 3D space
number z – Z coordinate in 3D space
Enables/disables shadow receiving of all 3D Models within the Entity at once.
boolean value – True if enabled, false if disabled.
Sets the rotation value of the Entity, in degrees. This will affect the rotation of every 3D Model within the Entity. Note that if you go past 360 degrees in either direction, the rotation will reset back to under 360 to avoid numbers getting extremely large. For example, if you pass 365 to this function and then checked the rotation with this.entity().rotation();, it would return 5.
number x – the X rotation of the Entity
number y – the Y rotation of the Entity
number z – the Z rotation of the Entity
Sets rotation value in Quaternion.
Quaternion value – The Quaternion rotation value to be set
Sets the scale of the Entity. This will affect the scale of every 3D Model within the Entity.
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
Applies a new texture to all 3D Models within the Entity. The texture should be present in Sprite Editor.
string name – The name of the texture to be applied.
if(health <= 0.5){ this.entity().setTexture('Damaged Texture'); }
Sets the visibility of the Entity; true if the Entity is visible, false if not.
boolean value – the visibility of the Entity.
Returns the transformation matrix of the Entity.
Mat4 the Mat4 transformation matrix of the Entity.
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.
AABB AABB object containing relative AABB data
Returns the “oriented bounding box” for the Entity relative to its parent. OBB is more precise but more performance-heavy than AABB.
OBB OBB object containing relative OBB data
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.
AABB AABB object containing world AABB data
Returns the “oriented bounding box” for the Entity. OBB is more precise but more performance-heavy than AABB.
OBB OBB object containing OBB data
Returns the entity’s position coordinates in the world (absolute position).
Vec3 the {x, y, z} world coordinates of the Entity
let pos = this.entity().worldPosition();
log('X World Position = ' + pos.x);
Returns the Entity’s rotation in the world (not relative to its parent) in degrees.
Vec3 the {x, y, z} world rotation of the Entity
let rot = this.entity().worldRotation();
log('World Rotation = ' + rot);
Returns the Entity’s rotation in the world (not relative to its parent) in Quaternion.
Quaternion the world rotation of the Entity in Quaternion
↑ Back to top
A node is a piece of functionality that exists within a Node Map. If you have an idea for a custom node, you can make one yourself and share it online as a .bbnode file with JSON formatting.
To create a custom node, you need a basic understanding of JSON formatting and a text editor of your choice. To modify a pre-existing node, see Customizing Nodes.
Let’s look at a simple example – the “Set Color” node. Here’s the full .bbnode file:
{
"name" : "Set Color",
"attributes": [
{
"name" : "Set",
"type" : "Boolean",
"connection" : "Input",
"editable" : false
},
{
"name" : "Done",
"type" : "Boolean",
"connection" : "Output",
"editable" : false
},
{
"name" : "Color",
"type" : "Color",
"connection" : "None",
"editable" : true
}
],
"script":"
function init(){
}
function update(dt){
}
function signal(name, value) {
//Check the incoming signals
if (name == 'Set' && value) {
//get the node attributes
let col = this.attribute('Color');
//set the entity color
this.entity().setColor(col.r, col.g, col.b, col.a);
//Emit signal to indicate the node finished
this.emitSignal('Done', true);
}
}
"
}
This results in the following node and attributes:

Now let’s look at it line by line.
"name" : "Set Color",
This defines what name this node will have.
"attributes": []
This array defines what attributes the node will have in the attributes sidebar. It also details any input or output connections the node will have. Please note that the Fields and Possible Values here are all cAsE sEnSiTiVe!
| Field | Description | Possible Values |
|---|---|---|
| name | Required. The name of the attribute or connection. | Any string *do not give two attributes in the same node the same name! |
| type | Required. What data type the attribute contains. | Asset Animation Boolean Color Dropdown Mesh Number Slider Text Vector2D Vector3D |
| connection | Required. Whether this attribute is an input or output connection. | Input Output None |
| editable | Required. Attribute: Whether this attribute is visible & editable in the attribute sidebar. Connection: Whether the name of this connection can be altered. |
true false |
| essential | Optional (defaults to false). If this field is set to true, then this attribute will be displayed on the Entity’s attribute sidebar when clicked in the asset window. You are marking this attribute as important enough to be accessible from the world view instead of just the entity’s mind map. | true false |
| hasVariance | Optional (for number or vector attributes only). If this field is set to true, then this attribute will display a variance field next to its value. (see Wave node documentation for an example) | true false |
| self | Optional. If you’d like your node to be able to be referenced by other nodes without using signals, set this to true to make the purple connection circle visible. (See requested() for more information) | “self”: { “visible” : true } “self”: { “visible” : false } |
| value | Optional field used to define a default value for the attribute. For instance, your Number type attribute could have a default value of 100 with “value”: 100. Value is required for a Dropdown type attribute because all possible values are pre-defined. |
Dropdown Example from Advanced Move node:
"value": {
"default": "kReplace",
"options": {
"Replace": "kReplace",
"Add": "kAdd",
"Multiply": "kMultiply"
}
}
Example for a Vector3D attribute (leaving the X and Z values blank with null): |
| sliderMin sliderMax sliderStepSize sliderDefaultValue |
Required fields for a Slider type attribute. sliderMin and sliderMax define the range of the slider, sliderStepSize defines the increment of the slider, and sliderDefaultValue defines the initial value of the slider. | Example of a Slider attribute:
{
"name": "My Slider",
"type": "Slider",
"connection": "None",
"editable": true,
"sliderMin": 0,
"sliderMax": 10,
"sliderStepSize": 2,
"sliderDefaultValue": 2
}
|
"script":"
Anything you put in this string will be inserted into the Script section of the Node. Since it’s all defined within a string, make sure to use single quotes (‘) instead of double quotes (“) to avoid terminating the string early.
If you save your .bbnode file as a .json file and use a program that has syntax highlighting (such as Visual Studio Code), this section will highlight with errors. This is because normal JSON doesn’t allow multiline strings; this is an area where the .bbnode format differs from JSON.
Here’s another script example, this time from the Jump node. This code snippet is entirely contained within the “script”: ” … ” section of the Jump.bbnode file.
//Input Signal variables let _enabled = true; //Node attribute variables let _jumpLimit; let _jumpForce; //working variables let _physics; let _jumpCount = 0; function init(){ //get the node attributes _jumpForce = this.attribute('Jump Force'); _jumpLimit = this.attribute('Jump Limit'); //Get and check the Physics status of this entity _physics = this.entity().physics(); if(_physics && _physics.type() != 'kDynamic'){ warning('Jump Node only works with [Dynamic] bodies. Enabling by default'); _physics.setType('kDynamic'); } } function start(){ } function update(dt){ } function signal(name, value){ //Check the incoming signals if(name == 'Jump' && value){ //check we have dynamic physics on the entity if(_physics){ //check here if the signal to jump again is valid //we need to check we are with the jump limit if(_jumpLimit == 0 || _jumpCount < _jumpLimit){ //calculate the jump force to be applied let vel = _physics.linearVelocity(); if(_jumpForce.x != null){ vel.x = _jumpForce.x; } if(_jumpForce.y != null){ vel.y = _jumpForce.y; } if(_jumpForce.z != null){ vel.z = _jumpForce.z; } //apply the jump velocity _physics.setLinearVelocity( vel.x, vel.y, vel.z ); //track the jump count _jumpCount++; } } } else if(name == 'Reset' && value){ //Signal to reset the jump so we just reset the //jumpcount variable _jumpCount = 0; } }
To import a node into BuildBox, drag it from your file explorer into the mind map of the Entity you’d like to add it to. Voilà!
If you drag your .bbnode into the mind map and nothing happens, that probably means there’s a typo somewhere.
– Make sure that each attribute includes all the required fields.
– Make sure that you have no trailing commas.
– A JSON Validator will give you errors based on the Script section, because as noted above, JSON doesn’t normally allow multiline strings. You can try pasting your .bbnode contents into a JSON Validator and then deleting the script section to look for errors elsewhere.
The Camera object can be aquired by calling this.scene().camera(). With it you can manipulate the attributes of your game’s camera.
| Function | Description |
|---|---|
| farPlane() |
Returns the far render distance of the camera. |
| fieldOfView() |
Returns the field of view of the camera. The field of view is the extent of the observable world that is seen at any given moment. |
| followForce() |
Returns the follow force of the camera. This determines how much ‘force’ the camera follows an object with. |
| followOffset() |
Returns the follow offset of the camera. The camera will follow the object from this many units away. |
| followThreshold() |
Returns the follow threshold of the camera. This determines how far the followed object can get from the camera before it starts moving. |
| nearPlane() |
Returns the near render distance of the camera. This is the minimum distance from the camera that an object will be rendered. |
| orthoScale() |
Returns the orthographic scale of the camera (only works if camera projection is orthographic) |
| position() |
Returns the relative position of the camera. It is important to note that if your camera is set to position follow the Character or Path, that will take precedence over a position set with setPosition(). This function will return {0, 0, 0} until the relative position is changed with setPosition(), even if you adjust the camera position in the settings. |
| projection() |
Returns the projection type of the camera. There are only two possibilities, kPerspective or kOrthogonal. |
| rotation() |
Returns the relative rotation of the camera. It is important to note that if your camera is set to rotation follow the Character or Path, that will take precedence over a rotation set with setRotation(). This function will return {0, 0, 0} until the relative rotation is changed with setRotation(), even if you adjust the rotation of your camera in the settings. |
| rotationFollowSmooth() |
Returns the rotation smoothness of the camera. The range is 0-1. This is like the coefficient of Quaternion.slerp(). |
| screenCenterRay() |
Casts a ray based on the center of the Camera. The object returned has the properties origin and direction. |
| screenRay(point) |
Casts a ray based on the given screen point. The object returned has the properties origin and direction. This is useful in coordination with Physic’s World’s rayTest(). |
| screenToWorld(screenPoint) |
Converts the given Vec2 screenPoint to a 3D World Position. |
| setFarPlane(value) |
Sets the far render distance of the camera. This is the maximum distance from the camera that an object will be rendered. |
| setFieldOfView(value) |
Sets field of view of the camera. The field of view is the extent of the observable world that is seen at any given moment. |
| setFollowForce(x, y, z) |
Sets the follow force of the camera. This determines how much ‘force’ the camera follows an object with. |
| setFollowOffset(x, y, z) |
Sets the follow offset of the camera. The camera will follow the object from this many units away. |
| setFollowThreshold(x, y, z) |
Sets the follow threshold of the camera. This determines how far the followed object can get from the camera before it starts moving. |
| setNearPlane(value) |
Sets the Near Render Distance of the camera. This is the minimum distance from the camera that an object will be rendered. |
| setOrthoScale(value) |
Sets the orthographic scale of the camera (only works if camera projection is orthographic) |
| setPosition(x, y, z) |
Sets the relative position of the camera. It is important to note that if your camera is set to position follow the Character or Path, that will take precedence over a position set with setPosition(). This function will not override a camera’s position in the settings, but adjust the position relative to the original camera position. |
| setPositionFollow(value) |
Sets which object the Camera will follow. There are four options you can pass. |
| setProjection(value) |
Sets the projection type of the camera. There are two possibilities: kPerspective or kOrthogonal. |
| setProjectionMatrix(matrix) |
Sets a custom projection matrix. |
| setRotation(x, y, z) |
Sets the relative rotation of the camera. It is important to note that if your camera is set to rotation follow the Character or Path, that will take precedence over a rotation set with setRotation(). This function will not override a camera’s rotation in the settings, but adjust the rotation relative to the original camera rotation. |
| setRotationFollow(value) |
Sets the object whose rotation the Camera will match. There are four options you can pass. “None” – Camera will not match anything for rotation |
| setRotationFollowSmooth(value) |
Sets the rotation smoothness of the camera. The range is 0-1. This is like the coefficient of Quaternion.slerp(). |
| setRotationQuat(value) |
Sets the “additional” rotation in Quaternion. Note that unlike in Entity, these “setRotation” and “setRotationQuat” are independent, meaning that the result rotation will be a sum of these two. |
| setWorldPosition(x, y, z) |
Sets the actual position of the camera, the same way it is set in the camera settings panel. Note that if the camera is set to follow position of a character or path, this function won’t work. Use setPosition() to change the camera’s position relative to the object it’s following. |
| worldPosition() |
Returns the actual position of the camera. This is the same position as the one set in the camera settings panel. |
| worldRotation() |
Returns the actual rotation of the camera. This is the same rotation as the one set in the camera settings panel. |
| worldToScreen(x, y, z) |
Projects a World (3D) position into Screen (2D) coordinates. |
Returns the far render distance of the camera.
number The Far Render Distance of the camera. This is the maximum distance from the camera that an object will be rendered.
Returns the field of view of the camera. The field of view is the extent of the observable world that is seen at any given moment.
number the field of view of the camera.
Returns the follow force of the camera. This determines how much ‘force’ the camera follows an object with.
Vec3 the {x, y, z} follow force of the camera.
Returns the follow offset of the camera. The camera will follow the object from this many units away.
Vec3 the {x, y, z} follow offset of the camera.
Returns the follow threshold of the camera. This determines how far the followed object can get from the camera before it starts moving.
Vec3 the {x, y, z} follow threshold of the camera.
Returns the near render distance of the camera. This is the minimum distance from the camera that an object will be rendered.
number The near render distance of the camera.
Returns the orthographic scale of the camera (only works if camera projection is orthographic)
number the orthographic scale of the camera
Returns the relative position of the camera. It is important to note that if your camera is set to position follow the Character or Path, that will take precedence over a position set with setPosition(). This function will return {0, 0, 0} until the relative position is changed with setPosition(), even if you adjust the camera position in the settings.
Vec3 the {x, y, z} relative position of the camera.
let camera = this.camera(); camera.setPositionFollow("Character"); log(camera.position()); // result: {0, 0, 0} camera.setPosition(0, 10, 0); // the camera still follows the Character, but 10 units higher log(camera.position()); // result: {0, 10, 0}
Returns the projection type of the camera. There are only two possibilities, kPerspective or kOrthogonal.
string “kPerspective” if the projection is Perspective, “kOrthogonal” if the projection is Orthogonal
Returns the relative rotation of the camera. It is important to note that if your camera is set to rotation follow the Character or Path, that will take precedence over a rotation set with setRotation(). This function will return {0, 0, 0} until the relative rotation is changed with setRotation(), even if you adjust the rotation of your camera in the settings.
Vec3 the {x, y, z} relative rotation of the camera.
let camera = this.camera(); camera.setPositionFollow("Character"); log(camera.rotation()); // result: {0, 0, 0}, regardless of camera settings camera.setRotation(30, 0, 0); // the camera still follows the Character, but rotated on the X axis log(camera.position()); // result: {30, 0, 0}
Returns the rotation smoothness of the camera. The range is 0-1. This is like the coefficient of Quaternion.slerp().
number the rotation follow smoothness/coefficient
Returns a ray cast at the center of the Camera. The object returned has the properties origin and direction.
Object the ray cast into the 3D world based on the screen point
Returns a ray cast at the given screen point. The object returned has the properties origin and direction. This is useful in coordination with Physic’s World’s rayTest().
Vec2 point – an {x, y} coordinate on the screen
Object the ray cast into the 3D world based on the screen point
function touchBegan(point){
let cam = this.scene().camera();
let ra = cam.screenRay(pt);
log(ra.origin);
log(ra.direction);
}
Converts the given Vec2 screenPoint to a 3D World Position.
Vec2 screenPoint – an {x, y} coordinate on the screen
Vec3 the {x, y, z} 3D world coordinate relative to the given Vec2 screenPoint
function touchMove(point){ // move an entity to the point where the user is touching the screen. let pos = this.scene().camera().screenToWorld(point); this.entity().setPosition(pos.x, pos.y, pos.z); }
Sets the far render distance of the camera. This is the maximum distance from the camera that an object will be rendered.
number value – the new far render distance of the camera. Minimum 100.
Sets field of view of the camera. The field of view is the extent of the observable world that is seen at any given moment.
number value – the field of view, from a range of 10-100. The smaller the number, the more “focused in” your field of view becomes.
Sets the follow force of the camera. This determines how much ‘force’ the camera follows an object with. Another way to think of this is the speed at which your camera reacts to the object’s movement.
number x – the x axis component of the follow force
number y – the y axis component of the follow force
number z – the z axis component of the follow force
Sets the follow offset of the camera. The camera will follow the object from this many units away.
number x – the x axis component of the follow offset
number y – the y axis component of the follow offset
number z – the z axis component of the follow offset
Sets the follow threshold of the camera. This determines how far the followed object can get from the camera before it starts moving. A 0 follow threshold means the camera will start moving as soon as the object does, whereas a 100 means the camera starts moving when the object is 100 units away. This function also accepts a Vec3 optionally instead of x, y, z.
number x – the x axis component of the follow threshold
number y – the y axis component of the follow threshold
number z – the z axis component of the follow threshold
Sets the Near Render Distance of the camera. This is the minimum distance from the camera that an object will be rendered.
number value – The Near Render Distance of the camera.
Sets the orthographic scale of the camera (only works if camera projection is orthographic)
number value – the new orthographic scale of the camera
Sets the relative position of the camera. It is important to note that if your camera is set to position follow the Character or Path, that will take precedence over a position set with setPosition(). This function will not override a camera’s position in the settings, but adjust the position relative to the original camera position.
number x – the relative x axis position
number y – the relative y axis position
number z – the relative z axis position
let camera = this.camera(); camera.setPositionFollow("Character"); log(camera.position()); // result: {0, 0, 0} camera.setPosition(0, 10, 0); // the camera still follows the Character, but 10 units higher log(camera.position()); // result: {0, 10, 0}
Sets which object the Camera will follow. There are four options you can pass.
1. “None” – Camera will not follow anything
2. “Game Path” – Game Path will be followed
3. “Character” – Any Entity that is considered a Character will be followed
4. The Asset attribute that will be followed
string/Asset – “None”, “Game Path”, “Character”, or Asset attribute
Sets the projection type of the camera. There are two possibilities: kPerspective or kOrthogonal. If an invalid string is passed, will default to perspective.
string – two possibilities: “kPerspective” or “kOrthogonal”
Sets a custom projection matrix.
Mat4 matrix – custom projection matrix
Sets the relative rotation of the camera. It is important to note that if your camera is set to rotation follow the Character or Path, that will take precedence over a rotation set with setRotation(). This function will not override a camera’s rotation in the settings, but adjust the rotation relative to the original camera rotation.
number x – the relative x axis rotation
number y – the relative y axis rotation
number z – the relative z axis rotation
let camera = this.camera(); camera.setPositionFollow("Character"); log(camera.rotation()); // result: {0, 0, 0}, regardless of camera settings camera.setRotation(30, 0, 0); // the camera still follows the Character, but rotated on the X axis log(camera.position()); // result: {30, 0, 0}
Sets the object whose rotation the Camera will match. There are four options you can pass.
1. “None” – Camera will not match anything for rotation
2. “Game Path” – Game Path’s rotation will be matched
3. “Character” – Any Entity that is considered a Character will be followed for rotation
4. The Asset attribute whose rotation the camera will match
string/Asset – “None”, “Game Path”, “Character”, or Asset attribute
Sets the rotation smoothness of the camera. The range is 0-1. This is like the coefficient of Quaternion.slerp().
number value – the new rotation follow smoothness/coefficient
Sets the “additional” rotation in Quaternion. Note that unlike in Entity, these “setRotation” and “setRotationQuat” are independent, meaning that the result rotation will be a sum of these two.
Quaternion value – the new rotation in Quaternion
Sets the actual position of the camera, the same way it is set in the camera settings panel. Note that if the camera is set to follow position of a character or path, this function won’t work. Use setPosition() to change the camera’s position relative to the object it’s following.
Take care when using setWorldPosition and setPosition together, as setPosition sets a relative position based on the camera’s world position.
number x – the x-axis component of the new world position
number y – the y-axis component of the new world position
number z – the z-axis component of the new world position
Returns the actual position of the camera. This is the same position as the one set in the camera settings panel.
Vec3 {x, y, z} position of the camera
Returns the actual rotation of the camera. This is the same rotation as the one set in the camera settings panel.
Quaternion the rotation of the camera in Quaternion
Projects a World (3D) position into Screen (2D) coordinates.
number x – the x-axis 3D coordinate
number y – the y-axis 3D coordinate
number z – the z-axis 3D coordinate
Vec2 the resulting 2D screen coordinates
The BackgroundMusic class can be used to control the Background Music of a UI Screen Node.
| Static Function | Description |
|---|---|
| play(sound, looped) |
Sets the audio track of the Background Music and plays it. |
| stop() |
Stops the Background Music. |
| setVolume(volume) |
Sets the volume of the Background Music, range 0 (muted) to 1 (max). |
| volume() |
Returns the volume of the Background Music, range 0 (muted) to 1 (max). |
Sets the audio track of the Background Music and plays it.
Sound sound – The new audio to play as Background Music. Sound is a Script node attribute.
boolean looped – Optional. Set the Background Music to loop if true, or stop after one play if false.
function start(){ let track2 = this.attribute('track2'); BackgroundMusic.play(track2); }

A screenshot showing the Sound attribute used in the code example.
Stops the Background Music.
Sets the volume of the Background Music, range 0 (muted) to 1 (max).
number – the new volume of the Background Music
Returns the volume of the Background Music, range 0 (muted) to 1 (max).
number – the volume of the Background Music
A 3D Model node is the 3D mesh that provides a shape for your character or object. An entity can contain many 3D Models.
| Function | Description |
|---|---|
| castsShadow() |
Returns whether this 3D Model casts shadow. |
| color() |
Returns the color of the 3D Model. |
| globalDepth() |
Returns the depth of the 3D Model in a 2D World. |
| isVisible() |
Returns if the 3D Model is visible. |
| localAABB() |
Returns the local “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). |
| mesh() | |
| position() |
Returns the 3D Model’s position relative to its Entity. |
| receivesShadows() |
Returns whether this 3D Model receives shadows. |
| rotation() |
Returns the rotation of the 3D model. |
| scale() |
Returns the scale of the 3D model. |
| setCastShadow(value) |
Enables/disables shadow casting of the 3D Model. |
| setColor(r, g, b, a) |
Sets the color of the 3D Model. |
| setGlobalDepth(value) |
Set the depth of the 3D Model in a 2D World. |
| setMesh(meshModel) |
Sets the mesh by using a Mesh Attribute value. A Mesh Attribute can be added to your script node by clicking the script node, then clicking “Add Attribute” in the bottom right of the screen. It is recommended to use this method when setting a mesh programmatically, because it avoids potential issues with multiple meshes with the same name. |
| setMesh(value) |
Sets the mesh by using a string name. |
| setPosition(x, y, z) |
Sets the position {x, y, z} of the 3D Model. |
| setReceiveShadows(value) |
Enables/disables shadow receiving of the 3D Model. |
| setRotation(x, y, z) |
Sets the rotation {x, y, z} of the 3D Model. |
| setScale(x, y, z) |
Sets the scale {x, y, z} of the 3D Model. |
| setTexture(name) |
Sets the texture of the 3D Model. Can be set with the name of the texture or with a texture attribute (see attribute()). |
| setTextureOffset(x, y) |
Sets the offset of the texture assigned to the 3D Model. The texture is repeated if this is used. |
| setTextureScale(x, y) |
Sets the scale of the texture assigned to the 3D Model. If the value is less than 0, the texture will be repeated. |
| setVisible() |
Sets the visibility of the 3D Model. |
| textureOffset() |
Returns the texture offset of the 3D Model. |
| textureScale() |
Returns the texture scale. |
| transformedAABB() |
Returns the relative “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). |
| transformedOBB() |
Returns the “oriented bounding box” for the 3D Model 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 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far). |
| worldOBB() |
Returns the “oriented bounding box” for the 3d Model. OBB is more precise but more performance-heavy than AABB. |
Returns whether this 3D Model casts shadow.
boolean – true if the 3D Model casts a shadow, false if not
Returns the color of the 3D Model. Each {red, green, blue, alpha} component is range 0-255.
Object – the {r, g, b, a} representation of the color.
Returns the global depth of the 3D Model. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.
number value – The global depth of the 3D Model
Returns if the 3D Model is visible.
boolean true if the 3D Model is visible, false if the 3D Model is not.
Returns the local “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).
AABB AABB object containing relative AABB data
Mesh Model the mesh object of the 3D Model
Returns the 3D Model’s position relative to its Entity.
Vec3 the {x, y, z} relative coordinates of the 3D Model.
function start(){ let pos = this.entity().component("3D Model").position(); log("position x: ", pos.x, " y: ", pos.y, " z:", pos.z); }
Returns whether this 3D Model receives shadows.
boolean – true if the 3D Model receives shadows, false if not
Returns the rotation of the 3D model.
Vec3 the {x, y, z} rotation of the 3D Model.
Returns the scale of the 3D model.
Vec3 the {x, y, z} scale of the 3D Model.
Sets whether this 3D Model casts a shadow.
boolean value – true if the 3D Model casts a shadow, false if not
Sets the color of the 3D Model.
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
Sets the global depth of the 3D Model. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.
number value – The global depth of the 3D Model
Sets the mesh by using a Mesh Attribute value. A Mesh Attribute can be added to your script node by clicking the script node, then clicking “Add Attribute” in the bottom right of the screen. It is recommended to use this method when setting a mesh programmatically, because it avoids potential issues with multiple meshes with the same name.
MeshModel mesh – The Mesh Attribute that the 3D Model will be set to.
let model = this.entity().component("CharacterBody"); model.setMesh(this.attribute("mySphere")); // mySphere was created in the right sidebar when the script node was open.
Sets the mesh by using a string name.
string value – name of the mesh that the 3D Model will be set to.
Sets whether this 3D Model receives shadows.
boolean value – true if the 3D Model receives shadows, false if not
Sets the position {x, y, z} of the 3D Model.
number x – The x-axis component of the position
number y – The y-axis component of the position
number z – The z-axis component of the position
Sets the rotation {x, y, z} of the 3D Model.
number x – The x-axis component of the rotation
number y – The y-axis component of the rotation
number z – The z-axis component of the rotation
Sets the scale {x, y, z} of the 3D Model.
number x – The x-axis component of the scale
number y – The y-axis component of the scale
number z – The z-axis component of the scale
Sets the texture of the 3D Model. Can be set with the name of the texture or with a texture attribute (see attribute()).
string name – The name of the texture to be applied to the 3D Model. Or
SpriteModel texture – The texture attribute to be applied to the 3D Model.
Sets the offset of the texture assigned to the 3D Model. The texture is repeated if this is used.
number x – the x offset of the texture
number y – the y offset of the texture
Sets the scale of the texture assigned to the 3D Model. If the value is less than 0, the texture will be repeated.
number x – the x scale of the texture
number y – the y scale of the texture
Sets the visibility of the 3D Model.
boolean value – true for visible, false for not visible.
Returns the texture offset of the 3D Model.
Vec2 the {x, y} texture offset of the 3D Model
Returns the texture scale.
Vec2 the {x, y} scale of the texture assigned to the 3D Model.
Returns the relative “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).
AABB AABB object containing relative AABB data
Returns the “oriented bounding box” for the 3D Model relative to its parent. OBB is more precise but more performance-heavy than AABB.
OBB OBB object containing relative OBB data
Returns the world (absolute) “axis-aligned bounding box” for the 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).
AABB AABB object containing world AABB data
Returns the “oriented bounding box” for the 3d Model. OBB is more precise but more performance-heavy than AABB.
OBB OBB object containing OBB data