Collider (Collider) is a component used to detect and respond to physical collisions. The engine provides the following types of colliders:
Type | Description | Applicable Scenarios |
---|---|---|
StaticCollider | Static collider, does not move but can collide with other objects | Ground, walls, and other static objects |
DynamicCollider | Dynamic collider, affected by the physics engine and can move freely | Movable objects, projectiles, etc. |
CharacterController | Collider specifically for character control | Player characters, NPCs, etc. |
Collider components are used to define the physical properties and collision behavior of objects. The Galacean physics system provides three types of colliders:
Dynamic Collider
Dynamic colliders can move freely and are affected by physical forces, suitable for movable objects that require physical simulation, such as projectiles and pushable boxes.
Static Collider
Static colliders are fixed in the scene and do not move, typically used to create fixed physical obstacles such as ground and walls.
Character Controller
Character controllers are colliders specifically designed for character movement, supporting features such as walking on slopes and climbing steps, suitable for character control in first-person or third-person games.
All collider types have the following common features:
Currently, four types of collision shapes
are supported, but the support varies among different backend physics packages, as shown below:
Name | Description | Supported Backend Physics Packages |
---|---|---|
BoxColliderShape | Box-shaped collision shape | physics-lite, physics-physx |
SphereColliderShape | Sphere-shaped collision shape | physics-lite, physics-physx |
PlaneColliderShape | Infinite plane collision shape | physics-physx |
CapsuleColliderShape | Capsule-shaped collision shape | physics-physx |
Transform Synchronization:
Collision shapes
can be set with local offsets and rotations relative to the entityCollision/Trigger Events: Colliders can generate collision and trigger events when interacting with other colliders. For detailed information on these events and how to handle them, please refer to the Collision Events documentation.
Collision Layer: Each collider can be assigned to a collision layer (Layer0 to Layer31), which is used to control collision relationships between different objects. By setting collision layers, you can flexibly control which objects can collide with each other and which cannot. For more information, please refer to the Collision Layer documentation.
Performance Optimization
Dynamic Collider Settings
Character Controller Configuration
Usage Scenarios
// Add a static collider
const staticCollider = entity.addComponent(StaticCollider);
// Add a dynamic collider
const dynamicCollider = entity.addComponent(DynamicCollider);
// Add a character controller
const characterController = entity.addComponent(CharacterController);