Skip to content

feat(server): expose collision-aware safe spawn resolution for generated Studio maps #367

Description

@RSamaium

Problem

RPGJS Studio is preparing a direct map-generation flow with an “Explore the map” action. Generated maps currently store a start point at the center. A generated element hitbox can cover that point. The runtime honors the start point / explicit coordinates through player.changeMap(...), but inspection of the current server/physics APIs did not find a public helper that resolves a nearby collision-free spawn for the actual player hitbox.

Proposed API

Add an opt-in server map API such as map.findSpawnPosition({ preferred: { x, y }, hitbox, maxDistance }), returning coordinates or null, and document its integration with player.changeMap. The exact public naming is open to framework maintainers.

Expected behavior

  • Evaluate the real map collider data and player hitbox, including Studio element hitboxes and map bounds.
  • Return a deterministic nearby traversable position, with clearance for the player to move.
  • Return null when no suitable location exists; never silently place the player in a collider or disable collisions.
  • Preserve existing explicit-position behavior unless the option/helper is used.
  • Test an occupied center, edge positions, narrow passages, and a fully blocked map.

Studio integration

The direct generation release will continue to use the existing exploration launcher. Automatic safe-spawn guarantees remain pending this API; no custom collision workaround is being added in the local game project.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions