Create a new CollisionComponent.
The ComponentSystem that created this Component.
The Entity that this Component is attached to.
The Entity that this Component is attached to.
The ComponentSystem used to create this Component.
Gets the rotational offset of the collision shape from the Entity rotation in local space.
Sets the rotational offset of the collision shape from the Entity rotation in local space. Defaults to identity.
Gets the local space axis with which the capsule, cylinder or cone-shaped collision volume's length is aligned.
Sets the local space axis with which the capsule, cylinder or cone-shaped collision volume's length is aligned. 0 for X, 1 for Y and 2 for Z. Defaults to 1 (Y-axis).
Gets whether checking for duplicate vertices should be enabled when creating collision meshes.
Sets whether checking for duplicate vertices should be enabled when creating collision meshes.
Gets whether the collision mesh should be treated as a convex hull.
Sets whether the collision mesh should be treated as a convex hull. When false, the mesh can
only be used with a static body. When true, the mesh can be used with a static, dynamic or
kinematic body. Defaults to false
.
Gets the enabled state of the component.
Sets the enabled state of the component.
Gets the total height of the capsule, cylinder or cone-shaped collision volume from tip to tip.
Sets the total height of the capsule, cylinder or cone-shaped collision volume from tip to tip. Defaults to 2.
Gets the positional offset of the collision shape from the Entity position along the local axes.
Sets the positional offset of the collision shape from the Entity position along the local
axes. Defaults to [0, 0, 0]
.
Gets the radius of the sphere, capsule, cylinder or cone-shaped collision volumes.
Sets the radius of the sphere, capsule, cylinder or cone-shaped collision volumes. Defaults to 0.5.
Gets the render asset id of the mesh collision volume.
Sets the render asset or asset id of the mesh collision volume. Defaults to null. If not set then the asset property will be checked instead.
Gets the type of the collision volume.
Sets the type of the collision volume. Can be:
Defaults to "box".
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Static
EVENT_Fired when two rigid bodies stop touching. The handler is passed an Entity that represents the other rigid body involved in the collision.
Static
EVENT_Fired when two rigid bodies start touching. The handler is passed the ContactResult object which contains details of the contact between the two rigid bodies.
Static
EVENT_Fired when a contact occurs between two rigid bodies. The handler is passed a ContactResult object which contains details of the contact between the two rigid bodies.
Static
EVENT_Fired when a rigid body enters a trigger volume. The handler is passed an Entity representing the rigid body that entered this collision volume.
Static
EVENT_Fired when a rigid body exits a trigger volume. The handler is passed an Entity representing the rigid body that exited this collision volume.
A collision volume. Use this in conjunction with a RigidBodyComponent to make a collision volume that can be simulated using the physics engine.
If the Entity does not have a RigidBodyComponent then this collision volume will act as a trigger volume. When an entity with a dynamic or kinematic body enters or leaves an entity with a trigger volume, both entities will receive trigger events.
The following table shows all the events that can be fired between two Entities: