Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit3bb1da2647

README.md

CapsuleCollider (component)

A capsule collision shape: a cylinder along the entity's local Y axis capped by hemispheres. This is the shape characters use, because a rounded bottom slides over small steps instead of catching on them.

Sizing

radius and height are in the entity's local space, multiplied by the entity's world scale. height is the full height of the cylindrical section, excluding the caps. Leave both unset and the capsule derives from the entity's model bounds, and follows the mesh when renderer.mesh.setVertices or renderer.mesh.update changes it: by the next physics step the capsule takes the new geometry's size and centre.

entity.find("player").component.add("CapsuleCollider", { radius = 0.3, height = 1.6 })
entity.find("pillar").component.add("CapsuleCollider", {})

Fields

FieldMeaning
radiusCapsule radius. Unset derives from model bounds.
heightCylindrical section height. Unset derives from model bounds.
isTriggerReport overlaps without blocking.
frictionSurface friction.
restitutionBounciness.
rollingResistanceHow strongly the surface resists a body rolling on it: a rolling body slows at this many times gravity on level ground, so a ball rolled at v stops after v^2 / (2 * rollingResistance * 9.81). 0 rolls on.
spinningResistanceThe same for a body spinning on the surface about the contact normal. 0 spins on.
surfaceThe surface the collider is made of, by name: one Physics.defineSurface defined gives it its friction, restitution and resistances in place of the fields above, and contacts, contact events and ray and shape casts report the name either way. Empty names none.
oneWayThe direction, in the collider's own frame, bodies pass through it along: a body moving that way goes through, and a body meeting it from the side the direction points to stands on it (a jump-through platform is {0, 1, 0}). Physics.passThrough(entity) drops a standing body through. Unset blocks from every side.
surfaceVelocityThe velocity, m/s in the collider's own frame, its surface moves at along itself while the collider stays put: friction carries what rests on it (a conveyor belt, a treadmill, an escalator). Write it at runtime to change the speed or direction. Unset holds the surface still.
contactTagThe tag the world's contact filter reads this collider by: Physics.setContactFilter(tagA, tagB, mode) makes two tags pass through each other ("ignore"), report contacts and push nothing ("sensor") or collide ("solid"). Empty names none.