Class: ColliderManager
Creates and updates colliders and collider event callbacks.
Constructors
Constructor
new ColliderManager(): ColliderManager;
Returns
ColliderManager
Methods
CreateBox()
static CreateBox(entity): Promise<number>;
Creates a box collider on an entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to update. |
Returns
Promise<number>
A promise that resolves to the created Collider.
CreateSphere()
static CreateSphere(entity): Promise<number>;
Creates a sphere collider on an entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to update. |
Returns
Promise<number>
A promise that resolves to the created Collider.
CreateCapsule()
static CreateCapsule(entity): Promise<number>;
Creates a capsule collider on an entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to update. |
Returns
Promise<number>
A promise that resolves to the created Collider.
Destroy()
static Destroy(entity, collider): Promise<boolean>;
Destroys a collider on an entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to update. |
collider | number | The Collider to destroy. |
Returns
Promise<boolean>
A promise that resolves to true if the collider was destroyed, or
false otherwise.
HasComponent()
static HasComponent(entity, collider): Promise<boolean>;
Checks whether an entity has a collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to inspect. |
collider | number | The Collider to check. |
Returns
Promise<boolean>
A promise that resolves to true if the entity has the collider, or
false otherwise.
GetEntity()
static GetEntity(collider): Promise<number>;
Gets the entity that owns a collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<number>
A promise that resolves to the owning Entity.
GetAllColliders()
static GetAllColliders(entity): Promise<number[]>;
Gets all colliders on an entity.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to inspect. |
Returns
Promise<number[]>
A promise that resolves to the list of Collider handles.
GetBoxColliderCenter()
static GetBoxColliderCenter(collider): Promise<vec3>;
Gets the center of a box collider.
An error is thrown if the collider is not a box collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<vec3>
A promise that resolves to the box collider center.
SetBoxColliderCenter()
static SetBoxColliderCenter(collider, center): Promise<void>;
Sets the center of a box collider.
An error is thrown if the collider is not a box collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
center | vec3 | The box collider center. |
Returns
Promise<void>
A promise that resolves when the center has been changed.
GetBoxColliderSize()
static GetBoxColliderSize(collider): Promise<vec3>;
Gets the size of a box collider.
An error is thrown if the collider is not a box collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<vec3>
A promise that resolves to the box collider size.
SetBoxColliderSize()
static SetBoxColliderSize(collider, size): Promise<void>;
Sets the size of a box collider.
An error is thrown if the collider is not a box collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
size | vec3 | The box collider size. |
Returns
Promise<void>
A promise that resolves when the size has been changed.
GetSphereColliderCenter()
static GetSphereColliderCenter(collider): Promise<vec3>;
Gets the center of a sphere collider.
An error is thrown if the collider is not a sphere collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<vec3>
A promise that resolves to the sphere collider center.
SetSphereColliderCenter()
static SetSphereColliderCenter(collider, center): Promise<void>;
Sets the center of a sphere collider.
An error is thrown if the collider is not a sphere collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
center | vec3 | The sphere collider center. |
Returns
Promise<void>
A promise that resolves when the center has been changed.
GetSphereColliderRadius()
static GetSphereColliderRadius(collider): Promise<number>;
Gets the radius of a sphere collider.
An error is thrown if the collider is not a sphere collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<number>
A promise that resolves to the sphere collider radius.
SetSphereColliderRadius()
static SetSphereColliderRadius(collider, radius): Promise<void>;
Sets the radius of a sphere collider.
An error is thrown if the collider is not a sphere collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
radius | number | The sphere collider radius. |
Returns
Promise<void>
A promise that resolves when the radius has been changed.
GetCapsuleColliderCenter()
static GetCapsuleColliderCenter(collider): Promise<vec3>;
Gets the center of a capsule collider.
An error is thrown if the collider is not a capsule collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<vec3>
A promise that resolves to the capsule collider center.
SetCapsuleColliderCenter()
static SetCapsuleColliderCenter(collider, center): Promise<void>;
Sets the center of a capsule collider.
An error is thrown if the collider is not a capsule collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
center | vec3 | The capsule collider center. |
Returns
Promise<void>
A promise that resolves when the center has been changed.
GetCapsuleColliderRadius()
static GetCapsuleColliderRadius(collider): Promise<number>;
Gets the radius of a capsule collider.
An error is thrown if the collider is not a capsule collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<number>
A promise that resolves to the capsule collider radius.
SetCapsuleColliderRadius()
static SetCapsuleColliderRadius(collider, radius): Promise<void>;
Sets the radius of a capsule collider.
An error is thrown if the collider is not a capsule collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
radius | number | The capsule collider radius. |
Returns
Promise<void>
A promise that resolves when the radius has been changed.
GetCapsuleColliderHeight()
static GetCapsuleColliderHeight(collider): Promise<number>;
Gets the height of a capsule collider.
An error is thrown if the collider is not a capsule collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<number>
A promise that resolves to the capsule collider height.
SetCapsuleColliderHeight()
static SetCapsuleColliderHeight(collider, height): Promise<void>;
Sets the height of a capsule collider.
An error is thrown if the collider is not a capsule collider.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
height | number | The capsule collider height. |
Returns
Promise<void>
A promise that resolves when the height has been changed.
GetIsTrigger()
static GetIsTrigger(collider): Promise<boolean>;
Gets whether a collider is a trigger.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to inspect. |
Returns
Promise<boolean>
A promise that resolves to true if the collider is a trigger, or
false otherwise.
SetIsTrigger()
static SetIsTrigger(collider, isTrigger): Promise<void>;
Sets whether a collider is a trigger.
Parameters
| Parameter | Type | Description |
|---|---|---|
collider | number | The Collider to update. |
isTrigger | boolean | Whether the collider is a trigger. |
Returns
Promise<void>
A promise that resolves when the trigger setting has been changed.
OnTriggerEnter()
static OnTriggerEnter(entity, onTriggerEnter): Promise<boolean>;
Registers a callback for trigger enter events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onTriggerEnter | (entity, collider) => void | The callback invoked when another collider enters the trigger. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnTriggerExit()
static OnTriggerExit(entity, onTriggerExit): Promise<boolean>;
Registers a callback for trigger exit events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onTriggerExit | (entity, collider) => void | The callback invoked when another collider exits the trigger. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnTriggerStay()
static OnTriggerStay(entity, onTriggerStay): Promise<boolean>;
Registers a callback for trigger stay events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onTriggerStay | (entity, collider) => void | The callback invoked while another collider remains in the trigger. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnCollisionEnter()
static OnCollisionEnter(entity, onCollisionEnter): Promise<boolean>;
Registers a callback for collision enter events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onCollisionEnter | (entity, collider) => void | The callback invoked when another collider begins colliding. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnCollisionExit()
static OnCollisionExit(entity, onCollisionExit): Promise<boolean>;
Registers a callback for collision exit events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onCollisionExit | (entity, collider) => void | The callback invoked when another collider stops colliding. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnCollisionStay()
static OnCollisionStay(entity, onCollisionStay): Promise<boolean>;
Registers a callback for collision stay events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onCollisionStay | (entity, collider) => void | The callback invoked while another collider remains in contact. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnUserTriggerEnter()
static OnUserTriggerEnter(entity, onUserTriggerEnter): Promise<boolean>;
Registers a callback for user trigger enter events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onUserTriggerEnter | (user) => void | The callback invoked when a user enters the trigger. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnUserTriggerExit()
static OnUserTriggerExit(entity, onUserTriggerExit): Promise<boolean>;
Registers a callback for user trigger exit events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onUserTriggerExit | (user) => void | The callback invoked when a user exits the trigger. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.
OnUserTriggerStay()
static OnUserTriggerStay(entity, onUserTriggerStay): Promise<boolean>;
Registers a callback for user trigger stay events.
Parameters
| Parameter | Type | Description |
|---|---|---|
entity | number | The Entity to observe. |
onUserTriggerStay | (user) => void | The callback invoked while a user remains in the trigger. |
Returns
Promise<boolean>
A promise that resolves to true if the callback was registered,
or false otherwise.