hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
1,051 lines (459 loc) • 12.4 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [Collider](./server.collider.md)
## Collider class
Represents a collider in a world's physics simulation.
When to use: defining collision shapes for rigid bodies or entities. Do NOT use for: gameplay queries; use `Simulation.raycast` or intersection APIs instead.
**Signature:**
```typescript
export default class Collider extends EventRouter
```
**Extends:** [EventRouter](./server.eventrouter.md)
## Remarks
Colliders are usually created via `RigidBody` or `Entity` options. You can also create and manage them directly for advanced use cases.
\*\*Category:\*\* Physics
## Constructors
<table><thead><tr><th>
Constructor
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[(constructor)(colliderOptions)](./server.collider._constructor_.md)
</td><td>
</td><td>
Creates a collider with the provided options.
Use for: configuring a collider before adding it to a simulation or rigid body.
</td></tr>
</tbody></table>
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[bounciness](./server.collider.bounciness.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The bounciness of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[bouncinessCombineRule](./server.collider.bouncinesscombinerule.md)
</td><td>
`readonly`
</td><td>
[CoefficientCombineRule](./server.coefficientcombinerule.md)
</td><td>
The bounciness combine rule of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[collisionGroups](./server.collider.collisiongroups.md)
</td><td>
`readonly`
</td><td>
[CollisionGroups](./server.collisiongroups.md)
</td><td>
The collision groups the collider belongs to.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[friction](./server.collider.friction.md)
</td><td>
`readonly`
</td><td>
number
</td><td>
The friction of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[frictionCombineRule](./server.collider.frictioncombinerule.md)
</td><td>
`readonly`
</td><td>
[CoefficientCombineRule](./server.coefficientcombinerule.md)
</td><td>
The friction combine rule of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isBall](./server.collider.isball.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a ball collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isBlock](./server.collider.isblock.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a block collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isCapsule](./server.collider.iscapsule.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a capsule collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isCone](./server.collider.iscone.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a cone collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isCylinder](./server.collider.iscylinder.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a cylinder collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isEnabled](./server.collider.isenabled.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is enabled.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isNone](./server.collider.isnone.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a none collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isRemoved](./server.collider.isremoved.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider has been removed from the simulation.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isRoundCylinder](./server.collider.isroundcylinder.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a round cylinder collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isSensor](./server.collider.issensor.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a sensor.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isSimulated](./server.collider.issimulated.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is simulated.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isTrimesh](./server.collider.istrimesh.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a trimesh collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isVoxel](./server.collider.isvoxel.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a voxel collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[isWedge](./server.collider.iswedge.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the collider is a wedge collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[parentRigidBody](./server.collider.parentrigidbody.md)
</td><td>
`readonly`
</td><td>
[RigidBody](./server.rigidbody.md) \| undefined
</td><td>
The parent rigid body of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[rawCollider](./server.collider.rawcollider.md)
</td><td>
`readonly`
</td><td>
[RawCollider](./server.rawcollider.md) \| undefined
</td><td>
The raw collider object from the Rapier physics engine.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[rawShape](./server.collider.rawshape.md)
</td><td>
`readonly`
</td><td>
[RawShape](./server.rawshape.md) \| undefined
</td><td>
The raw shape object from the Rapier physics engine.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[relativePosition](./server.collider.relativeposition.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The relative position of the collider to its parent rigid body.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[relativeRotation](./server.collider.relativerotation.md)
</td><td>
`readonly`
</td><td>
[QuaternionLike](./server.quaternionlike.md)
</td><td>
The relative rotation of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[scale](./server.collider.scale.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md)
</td><td>
The scale of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[shape](./server.collider.shape.md)
</td><td>
`readonly`
</td><td>
[ColliderShape](./server.collidershape.md)
</td><td>
The shape of the collider.
\*\*Category:\*\* Physics
</td></tr>
<tr><td>
[tag](./server.collider.tag.md)
</td><td>
`readonly`
</td><td>
string \| undefined
</td><td>
An arbitrary identifier tag of the collider. Useful for your own logic.
\*\*Category:\*\* Physics
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[addToSimulation(simulation, parentRigidBody)](./server.collider.addtosimulation.md)
</td><td>
</td><td>
Adds the collider to the simulation.
</td></tr>
<tr><td>
[enableCollisionEvents(enabled)](./server.collider.enablecollisionevents.md)
</td><td>
</td><td>
Enables or disables collision events for the collider. This is automatically enabled if an on collision callback is set.
</td></tr>
<tr><td>
[enableContactForceEvents(enabled)](./server.collider.enablecontactforceevents.md)
</td><td>
</td><td>
Enables or disables contact force events for the collider. This is automatically enabled if an on contact force callback is set.
</td></tr>
<tr><td>
[optionsFromBlockHalfExtents(halfExtents)](./server.collider.optionsfromblockhalfextents.md)
</td><td>
`static`
</td><td>
Creates collider options from a block's half extents.
</td></tr>
<tr><td>
[optionsFromModelUri(modelUri, scale, preferredShape)](./server.collider.optionsfrommodeluri.md)
</td><td>
`static`
</td><td>
Creates collider options from a model URI using an approximate shape and size.
</td></tr>
<tr><td>
[removeFromSimulation()](./server.collider.removefromsimulation.md)
</td><td>
</td><td>
Removes the collider from the simulation.
</td></tr>
<tr><td>
[setBounciness(bounciness)](./server.collider.setbounciness.md)
</td><td>
</td><td>
Sets the bounciness of the collider.
</td></tr>
<tr><td>
[setBouncinessCombineRule(bouncinessCombineRule)](./server.collider.setbouncinesscombinerule.md)
</td><td>
</td><td>
Sets the bounciness combine rule of the collider.
</td></tr>
<tr><td>
[setCollisionGroups(collisionGroups)](./server.collider.setcollisiongroups.md)
</td><td>
</td><td>
Sets the collision groups of the collider.
</td></tr>
<tr><td>
[setEnabled(enabled)](./server.collider.setenabled.md)
</td><td>
</td><td>
Sets whether the collider is enabled.
</td></tr>
<tr><td>
[setFriction(friction)](./server.collider.setfriction.md)
</td><td>
</td><td>
Sets the friction of the collider.
</td></tr>
<tr><td>
[setFrictionCombineRule(frictionCombineRule)](./server.collider.setfrictioncombinerule.md)
</td><td>
</td><td>
Sets the friction combine rule of the collider.
</td></tr>
<tr><td>
[setHalfExtents(halfExtents)](./server.collider.sethalfextents.md)
</td><td>
</td><td>
Sets the half extents of a simulated block collider.
</td></tr>
<tr><td>
[setHalfHeight(halfHeight)](./server.collider.sethalfheight.md)
</td><td>
</td><td>
Sets the half height of a simulated capsule, cone, cylinder, or round cylinder collider.
</td></tr>
<tr><td>
[setMass(mass)](./server.collider.setmass.md)
</td><td>
</td><td>
Sets the mass of the collider.
</td></tr>
<tr><td>
[setOnCollision(callback)](./server.collider.setoncollision.md)
</td><td>
</td><td>
Sets the on collision callback for the collider.
</td></tr>
<tr><td>
[setRadius(radius)](./server.collider.setradius.md)
</td><td>
</td><td>
Sets the radius of a simulated ball, capsule, cylinder, or round cylinder collider.
</td></tr>
<tr><td>
[setRelativePosition(position)](./server.collider.setrelativeposition.md)
</td><td>
</td><td>
Sets the position of the collider relative to its parent rigid body or the world origin.
</td></tr>
<tr><td>
[setRelativeRotation(rotation)](./server.collider.setrelativerotation.md)
</td><td>
</td><td>
Sets the relative rotation of the collider to its parent rigid body or the world origin.
</td></tr>
<tr><td>
[setScale(scale)](./server.collider.setscale.md)
</td><td>
</td><td>
Scales the collider by the given scalar. Only ball, block, capsule, cone, cylinder, round cylinder are supported.
</td></tr>
<tr><td>
[setSensor(sensor)](./server.collider.setsensor.md)
</td><td>
</td><td>
Sets whether the collider is a sensor.
</td></tr>
<tr><td>
[setTag(tag)](./server.collider.settag.md)
</td><td>
</td><td>
Sets the tag of the collider.
</td></tr>
<tr><td>
[setVoxel(coordinate, filled)](./server.collider.setvoxel.md)
</td><td>
</td><td>
Sets the voxel at the given coordinate as filled or not filled.
</td></tr>
</tbody></table>