Log inGet started
World

Small Brain. Big Clean.

Branchmain
Branchesmain
Commit0ede00712c

README.md

flyBody

A fruit fly's body as an entity tree under a root: head with eyes, antennae and a proboscis, thorax, striped abdomen, six two-segment legs on single-axis pivots, two wings. build stands it; update moves the root kinematically and poses every part from a motor command.

Exports

  • M.build(root, { length? }) -> Body — stand a fly under root, facing the root's -Z, length world units long (default 0.6).
  • body:update(dt, { speed?, turn?, proboscis?, flight?, jump? }) — one frame: walk at speed (world units per second), turn at turn (radians per second, positive left), extend the proboscis (0 to 1), beat the wings and hover (0 to 1), hop on jump.
  • body:eye() -> pos, dir, body:mouthPosition(), body:frontFeet(), body:heading() — where the fly looks from, feeds with, stands on, faces.
  • body:destroy() — take the parts down.
  • body.groundY — the floor height the feet rest on (default 0).

Usage

local FlyBody = require("~.flyBody")
local body = FlyBody.build(public.entity, { length = 0.6 })
function update(dt)
    body:update(dt, { speed = 0.3, turn = 0.1 })
end

Notes

  • The gait is a tripod: right front, left mid and right hind step together.
  • Every part is a built-in primitive mesh tinted through its Model, so the body needs no asset of its own.