Log inGet started
Package

DustKick.scene

Newest version

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.luau or per-scene overrides in this scene's scene.json (player.avatar_<mode> / camera.behavior_<mode>).
  • Per-entity overrides — in entrypoint.luau's localPlayerReady callback: 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 localPlayerReady callback: 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)

  1. scene.json v6 materializes static entities + lighting via the Luau scene_loader.module.
  2. The scene loader scans the sibling entrypoint.luau for 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, …).
  3. player_spawner.module ensures a Player entity exists and applies world.avatar_default_<mode> (or per-scene player.avatar_<mode> override). The avatar bundle combines mesh + skeleton + Locomotion + MovementState + CharacterController.
  4. camera_spawner.module ensures a primary camera exists and applies world.camera_default_<mode> (or per-scene override).
  5. 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 from world.<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.installLibrary before layers.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 in scene.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.json v6 does NOT carry a "player": { fov, position } block (that was pre-unification). Use world.*_default_<mode> for defaults and entrypoint.luau::onLocalReady → player.position.set for spawn position.
  • entrypoint.luau is 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" } }).