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?

Physics World – API Reference

By |

Physics World

These methods adjust the physics settings from the world menu. For more information, see the world options manual.

Function Description
checkSphereCollision(position, radius, filter)

Checks if anything collides with the sphere at the given position with the given radius. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, Entity.

disableDeactivation(value)

When a dynamic body is not moved for a few seconds, it will go into sleep mode. In sleep mode, the physics engine skips the body’s simulation. Sleep mode can be disabled with this method. By default, sleep mode is be enabled.

getSphereCollisions(position, radius, filter)

Returns colliders with a sphere at the given position with the given radius. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, Entity.

rayTest(from, to, filter)

Returns physics bodies that collide with a ray between the two given Vec3 coordinates. The object returned has the properties bodies and sensors.

Optional filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, Entity.

setSubSteps(value)

Sets the value of the sub steps setting in the world options menu.

setTimeWarp(value)

Sets the value of the time warp setting in the world options menu.

subSteps()

Returns the value of sub steps from the world options menu.

timeWarp()

Returns the value of time warp from the world options menu.


checkSphereCollision(position, radius, filter)

Checks if anything collides with the sphere at the given position with the given radius. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, entity.

Parameters

Vec3 position – the position of the sphere
number radius – the radius of the sphere
string filter – / AssetModel / Entity / optional: “kAll” the filter of items to look for

Returns

boolean true if there is a collision, false if not

↑ Back to top


disableDeactivation(value)

When a dynamic body is not moved for a few seconds, it will go into sleep mode. In sleep mode, the physics engine skips the body’s simulation. Sleep mode can be disabled with this method. By default, sleep mode is be enabled.

Parameters

boolean value – true to disable deactivation, false to enable it

↑ Back to top


getSphereCollisions(position, radius, filter)

Returns colliders with a sphere at the given position with the given radius. One use case for this method would be interating through all the colliders within a sphere and adding damage to them for an explosion. Filter has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, “kGround”, value from Asset Attribute, entity.

Parameters

Vec3 position – the position of the sphere
number radius – the radius of the sphere
string filter – / AssetModel filter / Entity filter the filter of items to look for

Returns

Object with properties {bodies, sensors} – an array of bodies and an array of sensors within the sphere

↑ Back to top


rayTest(from, to, filter)

Returns physics bodies that collide with a ray between the two given Vec3 coordinates. Optionally takes a filter parameter which has these possible values: “kAll”, “kSensor”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, value from Asset Attribute, entity.

The object returned by this function has the properties {bodies, sensors} which are each arrays. The bodies and sensors objects have the properties {object, hitPoint}.

Parameters

Vec3 from – the starting coordinate
Vec3 to – the ending coordinate
string filter – / AssetModel filter / Entity filter the filter of items to look for

Returns

Object with properties {bodies, sensors}.

// choose an object as the Selected Character with ray testing. pt is where the user tapped.

let ray = cam.screenRay(pt);
let rtst = this.scene().physicsWorld().rayTest(
        ray.origin,
        ray.origin.add(ray.direction.scale(100))
    );
    
    for (let i = 0; i < rtst.bodies.length; ++i) {
        let hit = rtst.bodies[i];
        Settings.selectedCharacter = hit.object.parentEntity().name();
        return;
    }
    

↑ Back to top


setSubSteps(value)

Sets the value of the sub steps setting in the world options menu.

Parameters

number value – the new sub steps value

↑ Back to top


setTimeWarp(value)

Sets the value of the time warp setting in the world options menu.

Parameters

number value – the new time warp value

↑ Back to top


subSteps()

Returns the value of sub steps from the world options menu.

Returns

number the sub step value

↑ Back to top


timeWarp()

Returns the value of time warp from the world options menu.

Returns

number the time warp value

↑ 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?

Camera – API Reference

By |

Camera

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

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
“Game Path” – Game Path’s rotation will be matched
“Character” – Any Entity that is considered a Character will be followed for rotation
The Asset attribute whose rotation the camera will match

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.


farPlane()

Returns the far render distance of the camera.

Returns

number The Far Render Distance of the camera. This is the maximum distance from the camera that an object will be rendered.

↑ Back to top


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.

Returns

number the field of view of the camera.

↑ Back to top


followForce()

Returns the follow force of the camera. This determines how much ‘force’ the camera follows an object with.

Returns

Vec3 the {x, y, z} follow force of the camera.

↑ Back to top


followOffset()

Returns the follow offset of the camera. The camera will follow the object from this many units away.

Returns

Vec3 the {x, y, z} follow offset of the camera.

↑ Back to top


followThreshold()

Returns the follow threshold of the camera. This determines how far the followed object can get from the camera before it starts moving.

Returns

Vec3 the {x, y, z} follow threshold of the camera.

↑ Back to top


nearPlane()

Returns the near render distance of the camera. This is the minimum distance from the camera that an object will be rendered.

Returns

number The near render distance of the camera.

↑ Back to top


orthoScale()

Returns the orthographic scale of the camera (only works if camera projection is orthographic)

Returns

number the orthographic scale of the camera

↑ Back to top


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.

Returns

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}

↑ Back to top


projection()

Returns the projection type of the camera. There are only two possibilities, kPerspective or kOrthogonal.

Returns

string “kPerspective” if the projection is Perspective, “kOrthogonal” if the projection is Orthogonal

↑ Back to top


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.

Returns

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}

↑ Back to top


rotationFollowSmooth()

Returns the rotation smoothness of the camera. The range is 0-1. This is like the coefficient of Quaternion.slerp().

Returns

number the rotation follow smoothness/coefficient

↑ Back to top


screenCenterRay()

Returns a ray cast at the center of the Camera. The object returned has the properties origin and direction.

Returns

Object the ray cast into the 3D world based on the screen point

↑ Back to top


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

Parameters

Vec2 point – an {x, y} coordinate on the screen

Returns

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

↑ Back to top


screenToWorld(screenPoint)

Converts the given Vec2 screenPoint to a 3D World Position.

Parameters

Vec2 screenPoint – an {x, y} coordinate on the screen

Returns

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

↑ Back to top


setFarPlane(value)

Sets the far render distance of the camera. This is the maximum distance from the camera that an object will be rendered.

Parameters

number value – the new far render distance of the camera. Minimum 100.

↑ Back to top


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.

Parameters

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.

↑ Back to top


setFollowForce(x, y, z)

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.

Parameters

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

↑ Back to top


setFollowOffset(x, y, z)

Sets the follow offset of the camera. The camera will follow the object from this many units away.

Parameters

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

↑ Back to top


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

Parameters

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

↑ Back to top


setNearPlane(value)

Sets the Near Render Distance of the camera. This is the minimum distance from the camera that an object will be rendered.

Parameters

number value – The Near Render Distance of the camera.

↑ Back to top


setOrthoScale(value)

Sets the orthographic scale of the camera (only works if camera projection is orthographic)

Parameters

number value – the new orthographic scale of the camera

↑ Back to top


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.

Parameters

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}

↑ Back to top


setPositionFollow(value)

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

Parameters

string/Asset – “None”, “Game Path”, “Character”, or Asset attribute

↑ Back to top


setProjection(value)

Sets the projection type of the camera. There are two possibilities: kPerspective or kOrthogonal. If an invalid string is passed, will default to perspective.

Parameters

string – two possibilities: “kPerspective” or “kOrthogonal”

↑ Back to top


setProjectionMatrix(matrix)

Sets a custom projection matrix.

Parameters

Mat4 matrix – custom projection matrix

↑ Back to top


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.

Parameters

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}

↑ Back to top


setRotationFollow(value)

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

Parameters

string/Asset – “None”, “Game Path”, “Character”, or Asset attribute

↑ Back to top


setRotationFollowSmooth(value)

Sets the rotation smoothness of the camera. The range is 0-1. This is like the coefficient of Quaternion.slerp().

Parameters

number value – the new rotation follow smoothness/coefficient

↑ Back to top


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.

Parameters

Quaternion value – the new rotation in Quaternion

↑ Back to top


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.
Take care when using setWorldPosition and setPosition together, as setPosition sets a relative position based on the camera’s world position.

Parameters

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

↑ Back to top


worldPosition()

Returns the actual position of the camera. This is the same position as the one set in the camera settings panel.

Returns

Vec3 {x, y, z} position of the camera

↑ Back to top


worldRotation()

Returns the actual rotation of the camera. This is the same rotation as the one set in the camera settings panel.

Returns

Quaternion the rotation of the camera in Quaternion

↑ Back to top


worldToScreen(x, y, z)

Projects a World (3D) position into Screen (2D) coordinates.

Parameters

number x – the x-axis 3D coordinate
number y – the y-axis 3D coordinate
number z – the z-axis 3D coordinate

Returns

Vec2 the resulting 2D screen coordinates

↑ 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?

Physics Component – API Reference

By |

Physics Component

This component is used for processing physics. You can find the physics menu in the Start node. To access these functions, you can use this.entity().physics().

Function Description
activateBody()

When the body type is “kDynamic” and “Always Active” is disabled, the body will become inactive after a short period of time. This function activates it again.

affectedAsset()

Returns the affected asset set for the physics component. This decides what type of assets this body can interact with.

angularDamping()

Returns the angular damping factor. Angular damping simulates drag; the higher the value, the more this entity will resist rotation.

angularVelocity()

Returns the current angular velocity value of the object.

clearVelocities()

Sets angular and linear velocity to zero.

collisionData()

Returns an object containing collision data for this entity. Optionally an Entity can be passed to get data about one entity specifically.

collisionGroup()

Returns the collision group of the object.

disableDeactivation(value)

A body will become inactive after a short period of time if left alone. If you disable deactivation, the body will always stay active. This is recommended for Linker entities.

friction()

Returns the body’s friction value.

gravity()

Returns the gravity value affecting the entity. If it hasn’t been adjusted for this entity, this method will return the gravity value of the Scene.

hasCollision(entity)

Returns true if the given entity collides with the current one.

isPhysics()

Returns true if physics is enabled on this entity, false if not.

linearDamping()

Returns the linear damping factor. Linear damping simulates drag; the higher the value, the more this entity will resist translation.

linearFactor()

Returns “position factor” of the physics component. The linear factor determines how the physics engine affects specific linear/position axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

linearVelocity()

Returns the current linear velocity value of the entity.

mass()

Returns the mass value of the entity. This defaults to 1.

mesh()

Returns the collision shape mesh if assigned. Null if a mesh is not being used as the collision shape.

parentEntity()

Returns the entity that this physics component belongs to.

predictedPosition(time)

Returns the predicted position of the body based on the given time.

rebuildShape()

Call this function to update the physics collision shape. This should be done if you change the shape or scale of your Entity in code.

restitution()

Returns the “Bounce” value of the physics component. The higher the value, the higher the bounce upon collision.

setAffectedAsset(value)

Sets the affected asset for the physics component. This decides what type of assets this body can interact with. Possible values: “kAll”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, “kPath”, Asset.

setAngularDamping(value)

Sets the angular damping factor, range 0-1. Angular damping simulates drag; the higher the value, the more this entity will resist rotation.

setAngularFactor(x, y, z)

Sets the “rotation factor” of the object. This determines how the physics engine affects specific angular/rotation axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

setAngularVelocity(x, y, z)

Sets the angular velocity value of the object.

setCollisionGroup(group)

Set the collision group of the entity.

setCreated(value)

Enables/disables everything that is connected to the “Start” node.

setFriction(value)

Sets the friction value for the body.

setGravity(x, y, z)

Sets gravity value affecting this entity. This will override the gravity value in the scene, and will not affect other objects.

setLinearDamping(value)

Sets the linear damping factor, range 0-1. Linear damping simulates drag; the higher the value, the more this entity will resist translation.

setLinearFactor(x, y, z)

Sets the “position factor” of the object. This determines how the physics engine affects specific linear/position axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

setLinearVelocity(x, y, z)

Sets the linear velocity of the entity.

setMass(value)

Sets the mass of the entity. A mass of 0 will not be affected by gravity.

setMesh(mesh)

Sets the mesh of the collision shape from a MeshModel script attribute.

setMesh(name)

Sets the mesh of the collision shape based on the name of the mesh.

setPhysics(value)

Enables/disables physics.

setRestitution(value)

Sets the “Bounce” value of the physics component. The higher the value, the higher the bounce upon collision.

setShapePosition(x, y, z)

Sets the collision shape position of the object. Note: you must call rebuildShape() after calling this for the change to be reflected in game.

setShapeRotation(x, y, z)

Sets the collision shape rotation of the object. Note: you must call rebuildShape() after calling this for the change to be reflected in game.

setShapeScale(x, y, z)

Sets the collision shape scale of the object. Note: you must call rebuildShape() after calling this for the change to be reflected in game.

setShapeType(type)

Sets the shape type. Highly recommended to use “kHullShape” over “kMeshShape”.

setType(value)

Sets the type of the physics body.

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 shape type of the collision shape.

type()

Returns the type of the physics body.


activateBody()

When the body type is “kDynamic” and “Always Active” is disabled, the body will get inactive after a short period of time. This function activates it back.

↑ Back to top


affectedAsset()

Returns the affected asset set for the physics component. This decides what type of assets this body can interact with. Possible values: “kAll”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, “kPath”, Asset.

Returns

string / Asset – the asset or group of assets this body can interact with

↑ Back to top


angularDamping()

Returns the angular damping factor. Angular damping simulates drag; the higher the value, the more this entity will resist rotation.

Returns

number – the angular damping factor, range 0-1

↑ Back to top


angularFactor()

Returns the “rotation factor” of the physics component. The angular factor determines how the physics engine affects specific angular/rotation axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

Returns

Vec3 the {x, y, z} components of the angular factor.

↑ Back to top


angularVelocity()

Returns the current angular velocity value of the object.

Returns

Vec3 the {x, y, z} components of the angular velocity.

↑ Back to top


clearVelocities()

Sets angular and linear velocity to zero.

↑ Back to top


collisionData()

Returns an object containing collision data for this entity. Optionally an Entity can be passed to get data about one entity specifically.

The returned object will have these properties (Data types in parenthesis). Keep in mind that a property is accessed like this: this.entity().physics().collisionData().totalImpulse;.

entity – the entity that’s being collided with (Entity)
totalImpulse – the total impulse from all collision points (number)
collisionPoints – an array of objects containing data about each point of collision (array of Objects). Each object in the array has these properties:
impulse – the impulse from the collision point (number)
normal – the normal of the collision point (Vec3)
position – the position of the collision point (Vec3)

Parameters

Entity (optional) an entity to check collision data with the current entity

Returns

Object – data object containing the information listed above

↑ Back to top


collisionGroup()

Returns the collision group of the object.

Returns

string possible values: kNone, kCharacter, kEnemy, kPlatform, kCoin

↑ Back to top


disableDeactivation(value)

A body will become inactive after a short period of time if left alone. If you disable deactivation, the body will always stay active. This is recommended for Linker entities.

Parameters

boolean value – true to keep the entity always active, false to allow it to become inactive as normal

↑ Back to top


friction()

Returns the body’s friction value. This can also be seen in the Start node unless altered at runtime.

Returns

number the friction value of the body

↑ Back to top


gravity()

Returns the gravity value affecting the entity. If it hasn’t been adjusted for this entity, this method will return the gravity value of the Scene.

Returns

number the current gravity value of the entity.

↑ Back to top


hasCollision(entity)

Returns true if the given entity collides with the current one.

Parameters

Entity entity the entity to check for a collision with

Returns

boolean true if the entities are colliding, false if not.

↑ Back to top


isPhysics()

Returns true if physics is enabled, false if not.

Returns

boolean true if physics is enabled, false if not.

↑ Back to top


linearDamping()

Returns the linear damping factor. Linear damping simulates drag; the higher the value, the more this entity will resist translation. Default value: 0

Returns

number the linear damping, range 0-1.

↑ Back to top


linearFactor()

Returns “position factor” of the physics component. The linear factor determines how the physics engine affects specific linear/position axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

Returns

Vec3 the {x, y, z} linear factor.

↑ Back to top


linearVelocity()

Returns the current linear velocity value of the entity.

Returns

Vec3 the {x, y, z} linear velocity of the entity.

↑ Back to top


mass()

Returns the mass value of the entity. This defaults to 1.

Returns

number the mass of the entity

↑ Back to top


mesh()

Returns the collision shape mesh if assigned. Null if a mesh is not being used as the collision shape.

Returns

MeshModel the object of the collision shape mesh

↑ Back to top


parentEntity()

Returns the entity that this physics component belongs to.

Returns

Entity the parent entity of the physics component

↑ Back to top


predictedPosition(time)

Returns the predicted position of the body based on the given time.

Parameters

number time – the number of seconds from now that you’d like to predict the position of the entity

Returns

Vec3 entity’s predicted {x, y, z} position after time based on its current Velocity.

↑ Back to top


rebuildShape()

Call this function to update the physics collision shape. This should be done if you change the shape or scale of your Entity in code.

↑ Back to top


restitution()

Returns the “Bounce” value of the physics component. The higher the value, the higher the bounce upon collision.

Returns

number the “Bounce” value of the physics component

↑ Back to top


setAffectedAsset(value)

Sets the affected asset for the physics component. This decides what type of assets this body can interact with. Possible values: “kAll”, “kEnemy”, “kPlatform”, “kCoin”, “kCharacter”, “kPath”, Asset.

Parameters

string value / Asset value – the asset or group of assets this body can interact with

↑ Back to top


setAngularDamping()

Sets the angular damping factor, range 0-1. Angular damping simulates drag; the higher the value, the more this entity will resist rotation.

Parameters

number value – the angular damping factor

↑ Back to top


setAngularFactor(x, y, z)

Sets the “rotation factor” of the object. This determines how the physics engine affects specific angular/rotation axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

Parameters

number x – the x component of the new angular factor
number y – the y component of the new angular factor
number z – the z component of the new angular factor

↑ Back to top


setAngularVelocity(x, y, z)

Sets the angular velocity value of the object.

Parameters

number x – the x component of the new angular velocity
number y – the y component of the new angular velocity
number z – the z component of the new angular velocity

↑ Back to top


setCollisionGroup(group)

Set the collision group of the entity.

Parameters

string group – possible values: kNone, kCharacter, kEnemy, kPlatform, kCoin

↑ Back to top


setCreated(value)

Enables/disables everything that is connected to the “Start” node.

Parameters

boolean value – true to enable, false to disable

↑ Back to top


setFriction(value)

Sets the friction value for the body. This can also be changed in the Start node.

Parameters

number value – the new friction value

↑ Back to top


setGravity(x, y, z)

Sets gravity value affecting this entity. This will override the gravity value in the scene, and will not affect other objects.

Parameters

number x – the x component of the new gravity
number y – the y component of the new gravity
number z – the z component of the new gravity

↑ Back to top


setLinearDamping(value)

Sets the linear damping factor, range 0-1. Linear damping simulates drag; the higher the value, the more this entity will resist translation.

Parameters

number value – the linear damping factor

↑ Back to top


setLinearFactor(x, y, z)

Sets the “position factor” of the object. This determines how the physics engine affects specific linear/position axes. For instance of x=0, the physics engine will not calculate physics for that axis. If x=2.0, it will calculate physics magnified by 2.

Parameters

number x – the x component of the new linear factor
number y – the y component of the new linear factor
number z – the z component of the new linear factor

↑ Back to top


setLinearVelocity(x, y, z)

Sets the linear velocity of the entity.

Parameters

number x – the x component of the new linear velocity
number y – the y component of the new linear velocity
number z – the z component of the new linear velocity

↑ Back to top


setMass(value)

Sets the mass of the entity. A mass of 0 will not be affected by gravity.

Parameters

number value – the new mass of the entity

↑ Back to top


setMesh(mesh)

Sets the mesh of the collision shape from a MeshModel script attribute.

Parameters

MeshModel mesh – the new mesh for the collision shape

↑ Back to top


setMesh(name)

Sets the mesh of the collision shape based on the name of the mesh.

Parameters

string name – the new mesh for the collision shape

↑ Back to top


setPhysics(value)

Enables/disables physics.

Parameters

boolean value – true to enable physics, false to disable

↑ Back to top


setRestitution(value)

Sets the “Bounce” value of the physics component. The higher the value, the higher the bounce upon collision.

Parameters

number value – the new “Bounce” value

↑ Back to top


setShapePosition(x, y, z)

Sets the collision shape position of the object. Note: you must call rebuildShape() after calling this for the change to be reflected in game.

Parameters

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

↑ Back to top


setShapeRotation(x, y, z)

Sets the collision shape rotation of the object. Note: you must call rebuildShape() after calling this for the change to be reflected in game.

Parameters

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

↑ Back to top


setShapeScale(x, y, z)

Sets the collision shape scale of the object. Note: you must call rebuildShape() after calling this for the change to be reflected in game.

Parameters

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

↑ Back to top


setShapeType(type)

Sets the shape type. Highly recommended to use “kHullShape” over “kMeshShape”.

Parameters

string type – Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”.

↑ Back to top


setType(value)

Sets the type of the physics body.
kStatic – body is static and will never be moved but other objects can collide with it. Used for ground or walls in your game.
kDynamic – body is fully dynamic and can bounce off of other object and be affected by gravity.
kKinematic – body can be moved by directly setting position and rotation and will not react to other bodies collision or gravity. Used as obstacles or elevator platforms.
kNone – no physics enabled

Parameters

string type – Possible values: kStatic, kDynamic, kKinematic, kNone

↑ Back to top


shapePosition()

Returns the position of the collision shape.

Returns

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

↑ Back to top


shapeRotation()

Returns the rotation of the collision shape.

Returns

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

↑ Back to top


shapeScale()

Returns the scale of the collision shape.

Returns

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

↑ Back to top


shapeType()

Returns the shape type of the collision shape.

Returns

string Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”.

↑ Back to top


type()

Returns the type of the physics body. kStatic – body is static and will never be moved but other objects can collide with it. Used for ground or walls in your game.
kDynamic – body is fully dynamic and can bounce off of other object and be affected by gravity.
kKinematic – body can be moved by directly setting position and rotation and will not react to other bodies collision or gravity. Used as obstacles or elevator platforms.
kNone – no physics enabled

Returns

string Possible values: kStatic, kDynamic, kKinematic, kNone

let ph = this.entity().physics();
if(ph && ph.type() == 'kDynamic'){
  //Dynamic mode
}else{
  //Static or Kinematic mode
}

↑ 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?

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?

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?

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?

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?