CollisionComponent
WL.CollisionComponent
Native collision component
Provides access to a native collision component instance
Kind: static class of WL
.collider ⇒ Collider
Kind: instance property of CollisionComponent
Returns: Collider - Collision component collider
.collider
Set collision component collider
Kind: instance property of CollisionComponent
Param | Type | Description |
---|---|---|
collider | Collider | Collider of the collision component. |
.extents ⇒ Array.<number>
Kind: instance property of CollisionComponent
Returns: Array.<number> - Collision component extents
If collider returns Sphere, only the first
component of the returned vector is used.
.extents
Set collision component extents
If collider returns Sphere, only the first component of the passed vector is used.
Kind: instance property of CollisionComponent
Param | Type | Description |
---|---|---|
extents | Array.<number> | Extents of the collision component, expects a 3 component array. |
.group ⇒ number
Kind: instance property of CollisionComponent
Returns: number - collision component group
The groups is a bitmask that is compared to other components in queryOverlaps
or the group in rayCast.
Colliders that have no common groups will not overlap with each other. If a collider
has none of the groups set for rayCast, the ray will not hit it.
Each bit represents belonging to a group, e.g.:
Example
// c belongs to group 2
c.group = (1 << 2);
// c belongs to group 0
c.group = (1 << 0);
// c belongs to group 0 *and* 2
c.group = (1 << 0) | (1 << 2);
(c.group & (1 << 2)) != 0; // true
(c.group & (1 << 7)) != 0; // false
.group
Set collision component group
Kind: instance property of CollisionComponent
Param | Type | Description |
---|---|---|
group | number | Group mask of the collision component |
.queryOverlaps() ⇒ Array.<CollisionComponent>
Query overlapping objects
Kind: instance method of CollisionComponent
Returns: Array.<CollisionComponent> - Collision components overlapping this collider.