Humanoid.component
This package holds more than this page lists. See all of its files in its world.
README.md
Humanoid
Marker component for entities carrying a skeleton conforming to the
standard humanoid bone layout (Synty / Unreal-Mannequin convention).
Content reads a humanoid body's bones and attachment sockets through this
component instead of re-walking the descendant tree, and seats items on
those sockets with :attach.
Bone naming convention
Hips
Spine_01 → Spine_02 → Spine_03 → Neck → Head
└ Eyes, Eyebrows, Jaw
UpperLeg_R / UpperLeg_L
LowerLeg_R / LowerLeg_L
Ankle_R / Ankle_L
Ball_R / Ball_L → Toes_R / Toes_L
Clavicle_R / Clavicle_L
Shoulder_R / Shoulder_L
Elbow_R / Elbow_L
Hand_R / Hand_L
IndexFinger_01..04 / Thumb_01..04 / Finger_01..04
Mixamo / Unity-Humanoid imports go through a bone-rename pass at import time (tracked separately).
Fields
| Field | Type | Notes |
|---|---|---|
height | number | Foot-to-head height in T-pose, metres. Default 1.8. |
eye_height | number | Foot-to-eyes height, metres. Default 1.65. |
bones | { [string]: entity } | Computed; bone-name → entity-proxy map. Re-walks on read. |
sockets | { [string]: entity } | Computed; role (righthand, head, …) → the bone filling it on this body, through the body's RetargetProfile. |
Methods
| Method | Returns | Notes |
|---|---|---|
:bone(name) | entity | nil | Nil-safe single-bone lookup; same as self.bones[name]. |
:socket(point) | entity | nil | The bone carrying a standard attachment point or viewpoint (the avatar root for origin), or the bone at a VRM bone name, a role, or an exact bone name. |
:attach(point, childId, opts?) | entity | nil | Seats childId on the socket bone, moved by opts.position / opts.rotation / opts.scale. A standard point seats it at that point's frame; a VRM bone name, a role or a bone name at the bone's origin, turned as the bone is. Position and scale are metres in that frame, whatever bone units the rig was authored in; rotation is relative to that frame, as a quaternion { x, y, z, w } or Euler degrees { pitch, yaw, roll }. opts.visual = true seats it visual only: every physics component on the item and under it is removed (avatarStandard.visualOnly) and a warning names them. Any other option, or a value in none of those forms, raises with the item left as it was. Returns the socket bone. |
:descriptor() | descriptor | nil | The body's descriptor under the avatar standard: VRM bones, optional chains, the 19 points and the viewpoint with their frames, expressions by tier, height and bounds, and the rules it breaks. Nil until the body has set up its skeleton. |
:validate(opts?) | { ok, problems, summary } | Every rule of the avatar standard the body breaks, each { rule, name, message }, and summary, one line per broken rule in the player's language for showing a player. The height rule holds the height the body stands in the world. opts.rules names the rules a game holds bodies to (type, bone, point, expression, height; default all). |
:detach(childId, parent?) | boolean | Takes an item attach seated off the body: it goes under parent (the root of the scene when nil), keeping where it stands in the world, and drops the record :attachments() lists. False when the item is not seated on this body. |
:attachments() | { { id, point, position, rotation, scale, visual, stripped } } | Every item seated with attach, with the point and transform it was seated with, whether it is seated visual only, and the physics components seating it so removed (stripped). An avatar body swap re-seats each on the new body, visual only again when it was. |
The sockets are slots of the Slot family: an Assembly on a humanoid lists
each role socket as a slot of that kind (righthand, head, ...) and fills it
with a part whose Part.fits names the role, seated the way :attach seats an
item (guides { path: "topics/assemblies" }).
The avatar standard
Every humanoid avatar is built around one standard, modules.avatarStandard, so
a game can rely on the avatar a visitor arrives with. Its 19 attachment points
are named the same on every body:
| Point | Where | Carried by |
|---|---|---|
origin | on the ground beneath the hips | the avatar root |
hat, hair | the crown of the head | head |
faceFront, faceCenter | the front and centre of the head at eye level | head |
neckBase | the base of the neck | the upper torso |
leftCollar, rightCollar | between the neck and each shoulder | the upper torso |
leftShoulderTop, rightShoulderTop | the top of each shoulder | each upper arm |
bodyFront, bodyBack | the front of the chest, the middle of the back | the upper torso |
waistFront, waistCenter, waistBack | around the waist | hips |
leftGrip, rightGrip | each palm, +Z out of the fist on the thumb's side | each hand |
leftSole, rightSole | the middle of each sole, on the ground, +Z toward the toes | each foot |
viewpoint (the eyes) seats an item the same way, so a first-person camera
attached there rides the head. A point's frame is the avatar's own axes (+Y up, +Z forward, +X the body's
left) on the body standing in a T-pose with its palms down, carried by the
anatomy of the bone under it: a sword seated on rightGrip along +Z leaves the
fist on the thumb's side on every body, however the rig's bones are rolled or
posed at rest. The VRM 1.0 bone names (rightHand, leftUpperLeg, head)
resolve to this body's bones too.
Positions and the height in :descriptor() are in the avatar's own space, the
space :attach takes its offsets in; scale is the avatar root's world scale,
so the body stands height * scale tall in the world. proportions sizes gear
to the body (head, shoulderWidth, hipWidth, torso, arm, leg, in
metres): a helmet scaled by proportions.head, a backpack by
proportions.shoulderWidth. :descriptor() also states the viewpoint (between the eyes, from eye bones or
in front of the head at eye level), the face expressions the body's blend
shapes answer (the VRM presets, the Oculus visemes and ARKit's 52), and its
height against the band the standard takes. The avatarStandard module's
README has the whole descriptor.
Usage
-- Read a specific bone
local h = entity(playerId).component.get("Humanoid")
local head = h.bones.Head -- entity proxy
local handR = h:bone("Hand_R") -- nil-safe lookup
-- Seat a hat on the crown and a sword in the right fist, on any humanoid body
local hat = entity.spawn("hat")
h:attach("hat", hat.id)
local sword = entity.spawn("sword")
h:attach("rightGrip", sword.id)
-- Mount a first-person camera at the eyes, riding the head
local cam = entity.spawn("eye_cam")
h:attach("viewpoint", cam.id)
-- How tall the player stands in the world
local d = h:descriptor()
print(d.height * d.scale)
Ragdolling a humanoid
animation.ragdoll(playerId) makes the body a ragdoll: bodies sized per body
part, hinged knees and elbows, cones at the shoulders, hips and neck. A
description names bones by the same roles as sockets (head, leftarm,
rightleg, ...), so it fits every humanoid body. The physics guide's
"Ragdolls" section (guides { path: "topics/physics" }) has the rest.
animation.ragdoll(playerId) -- collapse
animation.ragdoll(playerId, { limp = { "rightarm" } }) -- one arm hangs, the rest animates
animation.ragdoll(playerId, false) -- back to the animation
Tag convention
Bundles carrying a humanoid skeleton tag themselves with both
playerVisual AND humanoid in their .metadata. Tooling can filter
to humanoid-conforming visuals via
asset.list("bundle", nil, { fields = { tags = { "playerVisual", "humanoid" } } }).