Builtin Library
readme.md
physicsView
Publishes two capture views that draw the physics world as solid shaded geometry:
capture pass=physics— every collider as a solid surface on black.capture pass=physics_context— the same colliders over the scene's own meshes in dim grey, with real occlusion between the two.
Reading the image
Hue is the collider's role; lightness within that hue is its identity.
| Colour | Role |
|---|---|
| blue | static — fixed in world space, including a collider with no rigid body |
| orange | dynamic — simulated by the physics engine |
| green | kinematic — moved by script, pushing other bodies |
| magenta, translucent | sensor — produces events and no contact response |
A small palette of hues is nameable, so "the blue geometry is static" is readable straight off the picture. The lightness spread within a family comes from a stable hash of the entity's guid, so two neighbouring objects of the same role stay distinguishable and any one object keeps its colour between captures, across restarts, and on every machine. An entity's hue changes when its body type changes.
physicsView.legend() returns the same information as data — every drawn
collider with its colour, entity id, shape type, role, and whether its geometry
is the shape's true surface — which is how a colour in the image maps back to a
specific entity.
Which view to use
physics renders the collider layer alone, so it owns its depth buffer: a
collider tucked inside its mesh — a character's capsule, most commonly — is
visible, and colliders occlude each other correctly. Reach for it to see the
physics world itself.
physics_context keeps the scene's meshes, so a collider that sits inside one
reads as hidden. Reach for it to answer whether a collider is where its model
is.
Geometry fidelity
Box, sphere, capsule, cylinder, cone, convex, triangle-mesh and heightfield
colliders draw their real surface, and a compound draws its children folded
together. A shape the engine cannot triangulate draws its bounding box, and
physicsView.legend() reports exact = false for it.
Soft bodies and wheels
What the simulation holds without a collider surface draws as lines over the
colliders, from Physics.debugLines:
| Line | What it shows |
|---|---|
| soft body element, blue to yellow to red | its load: slack, half way, at the load it tears |
| small grey cross | a free particle |
| green octahedron | a pinned particle |
| magenta octahedron | a particle held to a rigid body |
| orange segment with a cyan tick | a contact between soft surfaces, and its normal |
| wheel ray, green or red | the suspension ray, on ground or in the air |
| wheel travel, blue to red | mount to tyre centre, by how much travel is taken up |
| white circle | the tyre's radius, across its axle |
| yellow cross with a cyan tick | where the tyre meets the ground, and the ground's normal |
The lines draw over the solid colliders, so a cage inside its own body's
surface stays visible. physicsView.lines() returns what the last capture
drew as lines, object by object, with the data behind each: a soft body's
diagnostics (inverted cells, self-crossings, maxLoad, loadedElements,
pinned and attached particles) and a wheel's grounded and compression.
The same lines draw in the edit-mode collider overlay.