Desktop.scene
- .metadata17 B
- README.md4.5 KB
- entrypoint.luau817 B
- scene.json297 B
README.md
[scene_name] Scene
One-paragraph description of what this scene shows or simulates.
Mental model — read man getting-started before writing scene code
This scene runs inside the unified world / scene / players / camera
flow. The engine spawns the local player and primary camera for
you when this scene loads as a root (non-additive); the spawners
read defaults from world.avatar_default_<mode> /
world.camera_default_<mode>. You don't spawn either yourself.
To customize for this scene:
- Pick defaults — set world-level slots in
.world_entrypoint.luauor per-scene overrides in this scene'sscene.json(player.avatar_<mode>/camera.behavior_<mode>). - Per-entity overrides — in
entrypoint.luau'slocalPlayerReadycallback:player:setAvatar(ref). These revert at scene unload because the player entity is destroyed. - Camera follow —
layers.active.camera.follow = entity_proxy(nil to fall back to the default follow-localPlayer rule). - Spawn position — in the
localPlayerReadycallback:player.entity.position = { x, y, z }. This is the canonical pattern; spawn position is NOT stored in scene.json.
Spawn flow (on non-additive load)
scene.jsonv6 materializes static entities + lighting via the Luauscene_loader.module.- The scene loader scans the sibling
entrypoint.luaufor top-level lifecycle functions and auto-registers each one against its canonical event (onLoad→ play-mode load,onEditLoad→ edit-mode load,localPlayerReady→ local-player-ready, …). player_spawner.moduleensures a Player entity exists and appliesworld.avatar_default_<mode>(or per-sceneplayer.avatar_<mode>override). The avatar bundle combines mesh + skeleton + Locomotion + MovementState + CharacterController.camera_spawner.moduleensures a primary camera exists and appliesworld.camera_default_<mode>(or per-scene override).localPlayerReady(player)fires once the local player is fully spawned + components reconciled.
scene.json v6 schema
{
"format": "scene",
"version": 6,
"entities": [],
"lighting": { ... },
"player": {
"required_in_edit": true,
"required_in_play": true,
"avatar_edit": null,
"avatar_play": null
},
"camera": {
"required_in_edit": true,
"required_in_play": true,
"behavior_edit": null,
"behavior_play": null
}
}
Semantics:
required_in_<mode>: false→ spawner skips that slot for that mode.<field>_<mode>: null→ inherit fromworld.<corresponding-slot>_<mode>.<field>_<mode>: "@..."→ scene-level override.avatar_<mode>: ""(empty string) → explicit opt-out — scripts own the avatar slot for that mode.
Prerequisites
- Libraries / packages this scene requires (
world.installLibrarybeforelayers.load). - Player template, character controller, or runtime services it expects.
Coordinate / lighting conventions
- Y is up; +Z is forward.
- Player default spawn:
[0, 5, 10]looking at the origin — adjust inscene.json::player. - Lighting setup in
scene.json::lighting(ambient, directional, point lights).
Notes
- Anything specific to THIS scene: gameplay flow, win/lose state, expected play duration.
- Coordinate convention: Y is up; +Z is forward.
scene.jsonv6 does NOT carry a"player": { fov, position }block (that was pre-unification). Useworld.*_default_<mode>for defaults andentrypoint.luau::onLocalReady → player.position.setfor spawn position.entrypoint.luauis auto-discovered; no explicit"entrypoint": "..."reference belongs in scene.json.- Lighting goes in
scene.json::lighting(ambient / directional / point_lights / clear_color / sky). - Edit mode is state-frozen —
update,fixedUpdate, and physics are SKIPPED. Pick edit-mode defaults accordingly.
Adding entities
Static entities at scene-load time go in scene.json::entities.
Dynamic spawns go in entrypoint.luau::onLoad() via
entity.spawn(...).id / sc.spawnModel(...) / etc.
Entities spawned from onLoad participate in layers.active:save() by
default. Mark them temporary (entity.spawn("name", { temporary = true }).id)
to exclude from saves — useful for debug markers and runtime helpers
that shouldn't be baked into the scene file.
Discover the available built-ins via asset.list({ tags = { "playerAvatar" } })
and asset.list({ tags = { "cameraBehavior" } }).