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. |
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
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
mesh()
Returns the collision shape mesh, if the If Collide node has one. Returns null if not.
Returns
Mesh Model the collision shape mesh
parentEntity()
Returns the entity that the If Collide node belongs to.
Returns
Entity the If Collide’s parent Entity
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.
setActive(value)
Enables/disables the If Collide node.
Parameters
boolean value – true to enable the node, false to disable it
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
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
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
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
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
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
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”
shapePosition()
Returns the position of the collision shape.
Returns
Vec3 the {x, y, z} position coordinates of the collision shape
shapeRotation()
Returns the rotation of the collision shape.
Returns
Vec3 the {x, y, z} rotation coordinates of the collision shape
shapeScale()
Returns the scale of the collision shape.
Returns
Vec3 the {x, y, z} scale coordinates of the collision shape
shapeType()
Returns the type of the collision shape.
Returns
string the collision shape type. Possible values: “kCubeShape”, “kSphereShape”, “kCylinderShape”, “kHullShape”, “kMeshShape”