Scene Path – API Reference

By |

Scene Path

The scene path is the path through the levels of your game. It is created using the start and end points on each level. To access your game’s Path object, use this.scene().path().

Function Description
anchorAtPosition(value)

Returns the anchor position and rotation at the given path position.

anchorPosition()

Returns the current anchor position of the path.

anchorRotationQuat()

Returns the current anchor rotation of the path in quaternion.

pathPosition()

Returns the current path position. The path position is simply how far along the path the game has moved.

pathSize()

Returns the path size.

pathTangent()

Returns the current path tangent.

positionOnPath(entity)

Takes an entity or 3D world position and returns the position along the game path.

setAutoPositionUpdate(value)

Enables/disables auto path update. If it is disabled, levels will not be created automatically along the game path.

setPathPosition(value)

Sets the current path position.


anchorAtPosition(value)

Returns the anchor position and rotation at the given path position.

Parameters

number value – the path position

Returns

Vec3 the {x, y, z} anchor position of the path at the given position

↑ Back to top


anchorPosition()

Returns the current anchor position of the path.

Returns

Vec3 the {x, y, z} anchor position of the path

↑ Back to top


anchorRotationQuat()

Returns the current anchor rotation of the path in quaternion.

Returns

quaternion the anchor rotation of the path

↑ Back to top


pathPosition()

Returns the current path position. The path position is simply how far along the path the game has moved.

Returns

number the current position along the path

↑ Back to top


pathSize()

Returns the path size.

Returns

Vec2 the {x, y} path size

↑ Back to top


pathTangent()

Returns the current path tangent.

Returns

Vec3 the {x, y, z} current path tangent

↑ Back to top


positionOnPath(entity)

Takes an entity or 3D world position and returns the position along the game path.

Parameters

Entity entity – the entity to find the game path position of or Vec3 pos a 3D world position

Returns

number the position on the game path of the given entity or 3D world position

↑ Back to top


setAutoPositionUpdate(value)

Enables/disables auto path update. If it is disabled, levels will not be created automatically along the game path.

Parameters

boolean value – true to enable auto position update, false to disable

↑ Back to top


setPathPosition(value)

Sets the current path position.

Parameters

number value – the new path position

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Settings – API Reference

By |

Settings

Settings is a dummy class that can be extended in any way to store user information. Every time the user minimizes app, this class is serialized and saved in JSON format. It is restored during next game session.

Code example in Buildbox:

// store the name of the selected character
Settings.selectedCharacter = this.entity().name();

// get the stored character name from Settings
let charName = Settings.selectedCharacter;

You can also see this code in action in the Variable Save and Variable Load nodes.

Variables set in the Settings class can be accessed and changed after export from within Xcode (iOS), Android Studio (Android), and Visual Studio 2017 (Windows). This can be useful for custom SDK integration, A/B testing, and more. Note: Windows Exe files cannot be edited post-export.

To access the Settings class in Android Studio, import PTPSettingsController. Then you can set variables with setSettingsValue(), continue on the above example: setSettingsValue(“selectedCharacter”, “‘Character1′”) or for an object variable, setSettingsValue(“myObjectVariable”, “{objectid: 123, myString:’my string here’}”).

To access the Settings class in Xcode or Visual Studio 2017, import BBRuntime/BBRuntimeShared.h and use getSettingsValue and setSettingsValue.

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Quaternion – API Reference

By |

Quaternion

The Quaternion class represents a quaternion. Quaternions are used to describe rotation in 3D space. Quaternion contains several helpful static functions, which can be called like this: Quaternion.multiply(quat1, quat2). Objects of the Quaternion class have 4 number properties: x, y, z, and w.

Function Description
inverse()

Inverts the quaternion.

toEuler()

Converts from Quaternion to Euler angles (in degrees).

Static Function Description
angle(quat1, quat2)

Returns the angle between two Quaternions.

fromEuler(pitch, yaw, roll)

Converts from Euler angles to Quaternion.

lerp(quat1, quat2, t)

Interpolates between two Quaternions using linear interpolation and returns the result.

lookAt(lookStart, lookEnd)

Returns a Quaternion oriented to the given 3D coordinates.

multiply(quat1, quat2)

Multiplies the given Quaternions and returns the result.

slerp(quat1, quat2, t)

Interpolates between two Quaternions using spherical spline interpolation and returns the result.


inverse()

Inverts the quaternion.

Returns

boolean true if the inversion was successful, false if not

↑ Back to top


toEuler()

Converts from Quaternion to Euler angles (in degrees).

Returns

Vec3 the {x, y, z} yaw, pitch, and roll Euler angles

↑ Back to top


angle(quat1, quat2)

Returns the angle between two Quaternions.

Parameters

Quaternion quat1 – the first Quaternion
Quaternion quat2 – the second Quaternion

Returns

number – the resulting angle

↑ Back to top


fromEuler(pitch, yaw, roll)

Converts from Euler angles to Quaternion.

Parameters

number pitch – the x-axis component
number yaw – the y-axis component
number roll – the z-axis component

Returns

Quaternion the resulting Quaternion

↑ Back to top


lerp(quat1, quat2, t)

Interpolates between two quaternions using linear interpolation and returns the result. Less accurate than slerp() but more efficient. The interpolation curve for linear interpolation between quaternions gives a straight line in quaternion space.

Parameters

Quaternion quat1 – the first Quaternion
Quaternion quat2 – the second Quaternion
number t the interpolation coefficient

Returns

Quaternion the resulting Quaternion

↑ Back to top


lookAt(lookStart, lookEnd)

Returns a Quaternion oriented to the given 3D coordinates.

Parameters

Vec3 lookStart – the first set of 3D coordinates
Vec3 lookEnd – the second set of 3D coordinates

Returns

Quaternion – the resulting Quaternion

let _target;

function start(){
    _target = this.scene().findFirst("Cube");
}

function update(dt){
    // rotate the projectile to face the target
    let currentQuat = this.entity().rotationQuat();
    let nextQuat = Quaternion.lookAt(this.entity().position(), _target.position());
    nextQuat = Quaternion.slerp(currentQuat, nextQuat, 0.5);
    this.entity().setRotationQuat(nextQuat);

    // move the projectile toward the target in an arcing movement
    let mat = Mat4.createRotation(nextQuat);
    let forward = Mat4.transformPoint(mat, new Vec3(1, 1, -1));
    let curPos = this.entity().position();
    this.entity().setPosition(
        curPos.x + 0.1 * forward.x,
        curPos.y + 0.1 * forward.y,
        curPos.z + 0.1 * forward.z);
}

↑ Back to top


multiply(quat1, quat2)

Multiplies the given Quaternions and returns the result.

Parameters

Quaternion quat1 – the first Quaternion
Quaternion quat2 – the second Quaternion

Returns

Quaternion – the resulting Quaternion

↑ Back to top


slerp(quat1, quat2, alpha)

Interpolates between two Quaternions using spherical spline interpolation and returns the result. More accurate than lerp() but less efficient. Spherical spline interpolation provides smooth transitions between different orientations and is often useful for animating models or cameras in 3D.

Parameters

Quaternion quat1 – the first Quaternion
Quaternion quat2 – the second Quaternion
number t the interpolation coefficient

Returns

Quaternion the resulting Quaternion

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Trail – API Reference

By |

Trail

A Trail is a node that creates a trail behind the Entity.

Function Description
globalDepth()

Returns the depth of the Trail in a 2D World.

setColor(r, g, b, a)

Sets the color of the trail.

setGlobalDepth(value)

Sets the depth of the Trail in a 2D World.

setUpVector(value)

Sets the “up vector” of the Trail. This changes the orientation of the tail, which is useful for 2D games.

upVector()

Returns the “up vector” of the Trail.


globalDepth()

Returns the global depth of the Trail node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Returns

number – The global depth of the Trail

↑ Back to top


setColor(r, g, b, a)

Sets the color of the trail.

Parameters

number red – the red component of the new color
number green – the green component of the new color
number blue – the blue component of the new color
number alpha – (Optional) the opacity component of the new color, max 255

let trail = this.entity().component("Trail");
trail.setColor(193, 66, 66); // set the trail to be red

↑ Back to top


setGlobalDepth(value)

Sets the global depth of the Animation node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Parameters

number value – The global depth of the Animation

↑ Back to top


setUpVector(value)

Sets the “up vector” of the Trail. This changes the orientation of the tail, which is useful for 2D games. The range is 0-1 for the x, y, and z values.

Parameters

Vec3 value – The new “up vector”

↑ Back to top


upVector()

Returns the “up vector” of the Trail.

Returns

Vec3 – The Trail’s “up vector”

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Vec2 – API Reference

By |

Vec2

The Vec2 class represents a vector in 2D space. Here is how you initialize one and get values from it.

let pos = new Vec2(0, 1);
log(pos); // output: {0, 1}
log(pos.x); // output: 0

Here’s more examples of its usage.

let a = new Vec2(1, 3);
let b = new Vec2(3, 7);
let sum = a.add(b); 
let length = a.length();
let sqrLength = a.sqrLength(); //squared length
let normalized = a.normalize();
let diff = a.sub(b);
let dotProduct = a.dot(b);
let distanceBetweenPoints = a.distance(b);

let factor = 2;
let scaled = a.scale(factor); 

let alpha = 0.5;
let lerp = a.lerp(b, alpha); 

let pivot = new Vec2(3,1);
let angle = Math.PI/4;
let rotated = rotateByAngle(pivot, angle);

let c = new Vec3(101, null);
let cxe = c.isXEmpty(); //false
let cye = c.isYEmpty(); //true

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Vec3 – API Reference

By |

Vec3

The Vec3 class represents a vector in 3D space. Here is how you initialize one and get values from it.

let pos = new Vec3(2, 0, 0);
log(pos); // output: {2, 0, 0}
log(pos.x); // output: 2

Here’s more examples of its usage.

let a = new Vec3(1, 3, 5);
let b = new Vec3(3, 7, 9);
log(a);
let sum = a.add(b); 
let length = a.length();
let sqrLength = a.sqrLength(); //squared length
let normalized = a.normalize();
let diff = a.sub(b);
let dotProduct = a.dot(b);
let crossProduct = a.cross(b);
let distanceBetweenPoints = a.distance(b);

let factor = 2;
let scaled = a.scale(factor); 

let alpha = 0.5;
let lerp = a.lerp(b, alpha); 

let c = new Vec3(101, null, null);
let cxe = c.isXEmpty(); //false
let cye = c.isYEmpty(); //true
let cze = c.isZEmpty(); //true

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Nodes – API Reference

By |

Nodes

A node, or component, is a piece of functionality that exists within a Mind Map. For more API information about specific nodes, check the drop down menu beneath Nodes in the sidebar. For information on accessing an Entity’s nodes, check the Entity reference.

Function Description
name()

Returns the name of the given node.


name()

Returns the name of the given node.

Returns

string – the name of the node

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

3D Model – API Reference

By |

3D Model

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.


castsShadow()

Returns whether this 3D Model casts shadow.

Returns

boolean – true if the 3D Model casts a shadow, false if not

↑ Back to top


color()

Returns the color of the 3D Model. Each {red, green, blue, alpha} component is range 0-255.

Returns

Object – the {r, g, b, a} representation of the color.

↑ Back to top


globalDepth()

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.

Returns

number value – The global depth of the 3D Model

↑ Back to top


isVisible()

Returns if the 3D Model is visible.

Returns

boolean true if the 3D Model is visible, false if the 3D Model is not.

↑ Back to top


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).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


mesh()

Returns

Mesh Model the mesh object of the 3D Model

↑ Back to top


position()

Returns the 3D Model’s position relative to its Entity.

Returns

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);
}

↑ Back to top


recievesShadows()

Returns whether this 3D Model receives shadows.

Returns

boolean – true if the 3D Model receives shadows, false if not

↑ Back to top


rotation()

Returns the rotation of the 3D model.

Returns

Vec3 the {x, y, z} rotation of the 3D Model.

↑ Back to top


scale()

Returns the scale of the 3D model.

Returns

Vec3 the {x, y, z} scale of the 3D Model.

↑ Back to top


setCastShadow(value)

Sets whether this 3D Model casts a shadow.

Parameters

boolean value – true if the 3D Model casts a shadow, false if not

↑ Back to top


setColor(r, g, b, a)

Sets the color 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


setGlobalDepth(value)

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.

Parameters

number value – The global depth of the 3D Model

↑ Back to top


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.

Parameters

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.

↑ Back to top


setMesh(value)

Sets the mesh by using a string name.

Parameters

string value – name of the mesh that the 3D Model will be set to.

↑ Back to top


setReceiveShadows(value)

Sets whether this 3D Model receives shadows.

Parameters

boolean value – true if the 3D Model receives shadows, false if not

↑ Back to top


setPosition(x, y, z)

Sets the position {x, y, z} of the 3D Model.

Parameters

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

↑ Back to top


setRotation(x, y, z)

Sets the rotation {x, y, z} of the 3D Model.

Parameters

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

↑ Back to top


setScale(x, y, z)

Sets the scale {x, y, z} of the 3D Model.

Parameters

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

↑ Back to top


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()).

Parameters

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.

↑ Back to top


setTextureOffset(x, y)

Sets the offset of the texture assigned to the 3D Model. The texture is repeated if this is used.

Parameters

number x – the x offset of the texture
number y – the y offset of the texture

↑ Back to top


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.

Parameters

number x – the x scale of the texture
number y – the y scale of the texture

↑ Back to top


setVisible()

Sets the visibility of the 3D Model.

Parameters

boolean value – true for visible, false for not visible.

↑ Back to top


textureOffset()

Returns the texture offset of the 3D Model.

Returns

Vec2 the {x, y} texture offset of the 3D Model

↑ Back to top


textureScale()

Returns the texture scale.

Returns

Vec2 the {x, y} scale of the texture assigned to the 3D Model.

↑ Back to top


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).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


transformedOBB()

Returns the “oriented bounding box” for the 3D Model 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 3D Model. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing world AABB data

↑ Back to top


worldOBB()

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

Returns

OBB OBB object containing OBB data

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

Animation – API Reference

By |

Animation Node

An Animation Node creates a 2D plane that plays a PNG sequence or displays an image.

Function Description
animation() Returns the Animation object of the Animation Node. This is the actual asset of the node.
color() Returns the color of the Animation node.
depth() Returns the depth of the Animation node.
globalDepth()

Returns the depth of the Animation in a 2D World.

is3DMode() Returns true if the Animation Node is in 3D mode, and false if not.
isBillboardMode()

Returns true if the Animation is in billboard mode. An Animation in billboard mode will always face the camera.

localAABB()

Returns the local “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

position()

Returns the position of the Animation relative to its parent Entity.

rotation()

Returns the rotation of the Animation relative to its parent Entity.

scale()

Returns the scale of the Animation relative to its parent Entity.

set3DMode(value)

Set 3D Mode of the Animation node on or off.

setAnimation(value)

Sets the Animation attribute within the Animation node. This is like the “asset” of the Animation node. An Animation can be stored as a Script Attribute.

setBillboardMode(value)

Set billboard mode of the Animation node on or off. An Animation in billboard mode will always face the camera.

setColor(r, g, b, a)

Set the color of the Animation node.

setDepth(value)

Set the depth of the Animation node.

setGlobalDepth(value)

Set the depth of the Animation node in a 2D World.

setPosition(pos)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

setPosition(x, y, z)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

setRotation(x, y, z)

Sets the rotation of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

setScale(x, y, z)

Sets the scale of the animation component relative to its parent Entity.

setVisible(value)

Sets the visibility of the 3D Model.

transformedAABB()

Returns the relative “axis-aligned bounding box” for the Animation. 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 Animation relative to its parent Entity. OBB is more precise but more performance-heavy than AABB.

worldAABB()

Returns the world (absolute) “axis-aligned bounding box” for the Animation. 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 Animation. OBB is more precise but more performance-heavy than AABB.


animation()

Returns the Animation object of the Animation Node. This is the actual asset of the node.

Returns

AnimationModel the Animation object of the Animation Node

↑ Back to top


color()

Returns the color of the Animation node. The range is 0-255 for each value (red, green, blue, alpha).

Returns

Object – the {r, g, b, a} representation of the Animation’s color.

↑ Back to top


depth()

Returns the depth of the Animation node. Depth decides which Animation is on top when the 3D Mode of the Animations is turned off. A higher value will be above a lower number.

Returns

Number – the depth of the Animation.

↑ Back to top


globalDepth()

Returns the global depth of the Animation node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Returns

number value – The global depth of the Animation

↑ Back to top


is3DMode()

Returns

boolean true if the Animation is in 3D mode, false if not

↑ Back to top


isBillboardMode()

Returns true if the Animation is in billboard mode. An Animation in billboard mode will always face the camera.

Returns

boolean true if the Animation is in billboard mode, false if not

↑ Back to top


localAABB()

Returns the local “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


position()

Returns the position of the Animation relative to its parent Entity.

Returns

Vec3 the {x, y, z} relative position coordinates of the Animation

↑ Back to top


rotation()

Returns the rotation of the Animation relative to its parent Entity.

Returns

Vec3 the {x, y, z} relative rotation of the Animation

↑ Back to top


scale()

Returns the scale of the Animation relative to its parent Entity.

Returns

Vec3 the {x, y, z} relative scale of the Animation

↑ Back to top


set3DMode(value)

Set 3D Mode of the Animation node on or off.

Parameters

boolean value – True to turn 3D mode on, false to turn it off

↑ Back to top


setAnimation(value)

Sets the Animation attribute within the Animation node. This is like the “asset” of the Animation node. An Animation can be stored as a Script Attribute.

Parameters

AnimationModel value – the AnimationModel to set the Animation attribute to.

↑ Back to top


setBillboardMode(value)

Set billboard mode of the Animation node on or off. An Animation in billboard mode will always face the camera.

Parameters

boolean value – True to turn billboard mode on, false to turn it off

↑ Back to top


setColor(r, g, b, a)

Sets the color of the Animation node. The range is 0-255 for each value (red, green, blue, alpha). Alpha is optional.

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 – the alpha component of the color (optional)

↑ Back to top


setDepth(value)

Sets the depth of the Animation node. Depth decides which Animation is on top when the 3D Mode of the Animations is turned off. A higher value will be above a lower number in the Scene.

Parameters

number value – The depth of the Animation

↑ Back to top


setGlobalDepth(value)

Sets the global depth of the Animation node. Depth decides which object is on top in a 2D World. A higher value will be above a lower number in the Scene.

Parameters

number value – The global depth of the Animation

↑ Back to top


setPosition(pos)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

Parameters

Vec3 pos – The new {x, y, z} relative coordinates of the Animation

↑ Back to top


setPosition(x, y, z)

Sets the position of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units.

Parameters

number x – The x component of the new position
number y – The y component of the new position
number z – The z component of the new position

↑ Back to top


setRotation(x, y, z)

Sets the rotation of the animation component relative to its parent Entity. Note: These coordinates are scaled down, so 100 units here = 10 world units. Can optionally take a Vec3 argument.

Parameters

number x – The x component of the new rotation
number y – The y component of the new rotation
number z – The z component of the new rotation

or

Vec3 – The {x, y, z} rotation

↑ Back to top


setScale(x, y, z)

Sets the scale of the animation component relative to its parent Entity.

Parameters

number x – The x component of the new scale
number y – The y component of the new scale
number z – The z component of the new scale

↑ Back to top


setVisible(value)

Sets the visibility of the 3D Model.

Parameters

boolean value – true for visible, false for not visible.

↑ Back to top


transformedAABB()

Returns the relative “axis-aligned bounding box” for the Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing relative AABB data

↑ Back to top


transformedOBB()

Returns the “oriented bounding box” for the Animation relative to its parent Entity. 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 Animation. These coordinates form a box with the minimum corner at (left, bottom, near) and the maximum corner at (right, top, far).

Returns

AABB AABB object containing world AABB data

↑ Back to top


worldOBB()

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

Returns

OBB OBB object containing OBB data

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?

If Collide – API Reference

By |

If Collide

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.
It is recommended to use “kHullShape” over “kMeshShape” as it is less memory intensive.

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.


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.

Returns

string the affected asset of the If Collide node: kNone, kCharacter, kEnemy, kPlatform, kCoin

↑ Back to top


collisionEntity()

Returns the last Entity that was collided with. Returns Null if there has never been a collision.

Returns

Entity the last Entity that was collided with

↑ Back to top


mesh()

Returns the collision shape mesh, if the If Collide node has one. Returns null if not.

Returns

Mesh Model the collision shape mesh

↑ Back to top


parentEntity()

Returns the entity that the If Collide node belongs to.

Returns

Entity the If Collide’s parent Entity

↑ Back to top


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.

    let col = this.entity().component("If Collide");
    col.setShapePosition(0, 1, 0);
    col.rebuildShape(); // call rebuildShape() for my position change to take effect.

↑ Back to top


setActive(value)

Enables/disables the If Collide node.

Parameters

boolean value – true to enable the node, false to disable it

↑ Back to top


setAffectedAsset(value)

Changes the affected asset of the If Collide node.

Parameters

string value – the new affected asset. Possible values: kNone, kCharacter, kEnemy, kPlatform, kCoin

↑ Back to top


setMesh(meshModel)

Sets the mesh of the collision shape using a MeshModel script attribute. See attribute() in the Script section for more information.

Parameters

MeshModel mesh – the new mesh of the collision shape

↑ Back to top


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.

Parameters

string mesh – the name of the new mesh

↑ Back to top


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.

Parameters

number x – the x coordinate position
number y – the y coordinate position
number z – the z coordinate position

↑ Back to top


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.

Parameters

number x – the x coordinate rotation
number y – the y coordinate rotation
number z – the z coordinate rotation

↑ Back to top


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.

Parameters

number x – the x coordinate scale
number y – the y coordinate scale
number z – the z coordinate scale

↑ Back to top


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.
It is recommended to use “kHullShape” over “kMeshShape” as it is less memory intensive.

Parameters

string type – The new collision shape type. Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”

↑ Back to top


shapePosition()

Returns the position of the collision shape.

Returns

Vec3 the {x, y, z} position coordinates of the collision shape

↑ Back to top


shapeRotation()

Returns the rotation of the collision shape.

Returns

Vec3 the {x, y, z} rotation coordinates of the collision shape

↑ Back to top


shapeScale()

Returns the scale of the collision shape.

Returns

Vec3 the {x, y, z} scale coordinates of the collision shape

↑ Back to top


shapeType()

Returns the type of the collision shape.

Returns

string the collision shape type. Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”

↑ Back to top

Did you find this page useful?

Please give it a rating:

Please provide some feedback!

This is very helpful to us.

Tell us how we can improve this post?