Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Basic usage for a character capsule

Capsule-shaped collider (cylinder with hemispherical caps).

Capsule-shaped collider (cylinder with hemispherical caps)Explicit capsule collider that users can add to customize collision shape. If present on an entity with RigidBody, overrides the automatic mesh-based collision.

A capsule is defined as a line segment with a radius, creating a shape that looks like a cylinder with rounded (hemispherical) ends.

The capsule is oriented along the Y-axis by default:

  • One hemisphere cap at (0, -halfHeight, 0)
  • One hemisphere cap at (0, +halfHeight, 0)

Total height = 2 * halfHeight + 2 * radius

Common uses:

  • Character controllers
  • Humanoid bodies
  • Cylindrical objects (cans, pipes, limbs)
  • Projectiles with elongated shapes
Note
Capsules roll smoothly and are more stable than cylinders
Very efficient for collision detection
The offset member is applied to the created physics shape when building the collision shape.
collider.halfHeight = 0.8f; // Cylinder part is 1.6m tall
collider.radius = 0.3f; // Total height = 1.6 + 0.6 = 2.2m
entity.AddComponent<Physics::Component::CapsuleCollider>(core, collider);
Definition CapsuleCollider.hpp:63
float radius
Radius of the capsule (both cylinder and hemisphere caps).
Definition CapsuleCollider.hpp:68
float halfHeight
Half height of the cylindrical part (distance from center to cap start).
Definition CapsuleCollider.hpp:65

usage for a character capsule