Ember is discontinued. It still works, but it gets no more updates or support. Back to uayi.org
Home · Terrified Gorillas · Glimmerwood · Starfall Hollow · ‹ Prev Next ›
Ember
Download

Making games

Physics and colliders

Ember uses Jolt Physics at a fixed 60 steps per second. An object takes part in physics when it has a Collider (Inspector: Collider & Physics).

Getting a collider

Body types

Type Moves? Use it for
Static never level geometry, buildings, terrain
Kinematic when you move it (script, animation); pushes dynamic things moving platforms, doors, elevators
Dynamic by physics: falls, bounces, gets pushed crates, balls, players, cars

Shapes

Shape What it is Use it for
Exact mesh the model's real triangles level geometry, ramps, buildings (static / kinematic only)
Convex hull a tight shrink-wrap around the model props that fall, roll and get pushed
Box, sphere, capsule simple shapes; Fit to model sizes and centres them fastest; capsules for characters
Terrain the terrain's height field plus a capsule per solid tree added automatically

A dynamic object set to Exact mesh uses a convex hull instead, because physics engines can't simulate moving triangle meshes. Lock rotation keeps a dynamic body upright (characters).

The selected object's collider is drawn in the viewport (green for solid, blue for a trigger). The physics button in the viewport toolbar shows every collider.

Triggers

A trigger collider doesn't block anything. When something enters or leaves it, both objects' scripts get on_trigger_enter(other) / on_trigger_exit(other) (and the visual-script events On Trigger Enter / Exit). Use triggers for pickups, checkpoints, goal zones and doors.

Collisions

on_collision(other, hit) runs when two solid bodies start touching; hit.point, hit.normal and hit.speed describe the impact. Objects with Crash Deformation dent where they're hit hard (see Characters, cars and sound).

Water

Dynamic bodies inside a Water object float: Jolt buoyancy uses the same wave function the renderer draws, so boats bob on the visible waves. water_height(x, z) gives the surface height in scripts.

Settings

Project Settings > Physics: gravity, tick rate (20–240 Hz), auto colliders on spawn, default friction and bounciness. Scripts can change gravity (scene.gravity(vec3(0, -4, 0))) and slow time (scene.time_scale(0.3)).

Joints

A Joint connects an object's body to another body, or to a fixed point in the world. Add one with Add Component > Joint; it also gives the object a dynamic body if it doesn't have one.

Type Use it for Settings
Hinge doors, wheels, flaps, see-saws pivot, axis, angle limits, motor speed (degrees/s) and strength
Ball swinging lamps, chains, ragdoll-ish limbs pivot
Slider drawers, lifts, pistons axis, distance limits, motor speed (m/s)
Spring bouncy platforms, wobbly antennas length, stiffness (Hz), damping
Distance ropes: never further apart than the length minimum and maximum distance
Fixed glue two objects together until they're pulled apart
local door = scene.find("Door")
door:add_joint{ type = "hinge", target = "Frame", anchor = vec3(-0.5, 0, 0), axis = vec3(0, 1, 0), min = -100, max = 0 }
door:set_motor(60)                  -- swing open at 60 degrees a second
print(door.joint_position)          -- the hinge angle in degrees (slider: metres)
door:remove_joint()

In scene files and MCP the component is "joint": {"type": "hinge", "target": "Frame", "anchor": [...], "axis": [...], "limits": true, "min": -100, "max": 0, "motor_speed": 0, "motor_force": 0, "break_force": 0, "min_distance": -1, "max_distance": -1, "spring_frequency": 2, "spring_damping": 0.3}.

Not included yet

Soft bodies aren't built. Crash deformation moves the model's vertices but doesn't change its collision shape. Joints are made when play starts and aren't edited live (remove and add them again from a script).

Lava

Add Component > Lava (or tick Lava on a Water component, or the Easy tab's Lava button) makes a pool or sea of molten rock: a slowly flowing, cracked crust with glowing seams that light up with bloom, brightest where it meets the shore.

Cloth

Add Component > Cloth hangs a sheet of fabric from the object: flags, curtains, banners, sails, capes, a tablecloth. It's simulated (Verlet integration with stretch, shear and bend constraints), blown by wind with gusts, and during play it drapes over the level's colliders.

Setting
Size, Detail metres; points along each side (more = smoother, slower)
Held at top edge (curtain), top corners (hammock), left edge (flag), four corners, or nothing (it falls)
Stiffness, Air resistance, Gravity how stretchy, floaty and heavy it is
Wind, Gusts m/s added to scene.wind(), and how much it varies
Collide drape over colliders while playing (the cloth doesn't push objects)
Image, Colour, Roughness how it looks (both sides are drawn)

The held points follow the object: move or animate it and the cloth follows.

scene.wind(vec3(6, 0, 2))                               -- wind for every cloth
local flag = scene.spawn{ name = "Flag", position = vec3(0, 4, 0),
                          cloth = { size = { 2, 1.3 }, pin = "left", tint = { 0.2, 0.3, 0.9, 1 } } }
self.entity:add_cloth{ size = { 1.2, 1.8 }, pin = "top", tint = { 0.6, 0.1, 0.1, 1 } }   -- a cape
self.entity:pin_cloth(1, false)                         -- let go of a point (numbered from 1, row by row from the top)
local p = flag:cloth_point(16)                          -- where a point is now; flag:cloth_points() = how many
flag.cloth_wind = vec3(0, 0, 8)

Cloth isn't saved mid-flap: it starts hanging straight each time the scene loads.

Ember 1.1 documentation. Found a mistake? The source of this page is site/docs/physics.md in the Ember source.