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?