Respawn Areas Entity
The respawn entity configures automatic respawning for objects including NPCs, enemies, and resource nodes placed on a map respawn area layer.
Managing respawn areas in the admin panel
Respawn areas are in the Respawn section of the admin sidebar, under Respawn Areas (/reldens-admin/respawn). Each row links a respawn area object to the map layer where its instances spawn:
To create a respawn area:
- Paint the spawn tiles in a map layer whose name contains respawn-area, and create the respawn area object in Game Objects > Objects on that layer (see the "Requirements Checklist" below and Objects Entity).
- Log in to the admin panel at /reldens-admin and open Respawn > Respawn Areas.
- Click Create New (the form opens at /reldens-admin/respawn/edit).
- Select the Object ID (required), the respawn area object.
- Fill in the Respawn Time in milliseconds (for example 20000) and the Instances Limit (for example 12), based on the desired gameplay balance.
- Fill in the Layer (required): the exact map layer name, the same value as the object layer_name.
- Click Save and restart the server: the respawn areas are created with the room world.
In the form, r marks a required field. Several respawn rows can share the same layer, for example two enemy types on one forest layer: create the second row with Duplicate and change the object.
Key Properties
- object_id: Reference to the objects entity (the respawn area object)
- respawn_time: Time in milliseconds before a defeated or depleted instance respawns
- instances_limit: Number of instances spawned at the same time
- layer: Tilemap layer for respawn placement, it must match the object layer_name exactly
How Respawn Works
- The respawn area is an objects row with class_type 7 (MultipleObject) and "shouldRespawn": true in its private_params, placed on a map layer whose name contains respawn-area.
- When the room world is created, the respawn system collects the layer tiles with a non-zero value as the spawn pool and loads the respawn rows of that layer.
- For each row it creates instances_limit child instances (for example EnemyObject or a custom class like the rocks) at random free tiles of the layer.
- When an instance is defeated or depleted (an enemy dies in battle, a rock is mined), its sprite is hidden and the timer starts based on respawn_time.
- After the timer expires, the same instance is restored at a new random tile of the layer: it stays hidden for respawnStateTime milliseconds while the position is synced, then it becomes active and visible again.
Use Cases
- Enemy Respawn: Enemies respawn after defeat for grinding
- Collectible Respawn: Collectible objects (chests, pickups) reappear after use
- NPC Respawn: NPCs return after being killed
- Resource Nodes: Harvestable resources regenerate (for example the mining rocks)
Instance Limits
The instances_limit property controls how many copies of the object exist simultaneously:
- 0: No instance is spawned
- 1: Only one instance at a time (it respawns after its defeat)
- N: N instances active simultaneously, each one respawning on its own timer
The instances are created once when the room is created and reused on every respawn, so the count never grows. Each instance uses a different tile of the layer, so paint enough spawn tiles for all of them.
Respawn Behavior
- Random Location: Every respawn picks a new random tile of the respawn area layer
- Timed: Respawn after the fixed respawn_time delay of the row
- Capped: Limit concurrent instances per area with instances_limit
- Shared Layers: Several respawn areas can use the same layer, each with its own respawn row (for example the Tree and Tree Punch enemies on merge-respawn-area-monsters)
Requirements Checklist
- objects row:
- class_type 7, tile_index NULL, enabled 1 (a disabled object is skipped with a warning).
- layer_name equal to the map layer name and to the respawn layer.
- private_params with "shouldRespawn": true (without it the object is silently skipped), the child class ("childObjectType": 4 for enemies or "childObjectClassKey" for a custom class), "hasState": true and "respawnStateTime": 100 so the client never shows the sprite sliding to its new position.
- objects_assets row with the spritesheet used by the spawned instances.
- Map layer whose name contains respawn-area, with non-zero tiles where the instances can spawn.
Database Relations
- objects: Parent object to respawn
Implementation
Internally, RespawnPlugin creates a RoomRespawn per respawn area layer (lib/respawn/server/room-respawn.js), and every spawned instance gets an ObjectRespawnBehavior (lib/respawn/server/object-respawn-behavior.js) that runs the hide, wait, move and show cycle. Custom object classes can hook into that cycle with the optional onBeforeRestore(room), onAfterRestore(room) and onSetActive(room) methods.
Example Configuration
- Boss Enemy: respawn_time=1800000 (30 minutes), instances_limit=1
- Regular Enemy: respawn_time=60000 (1 minute), instances_limit=5
- Collectible Item: respawn_time=300000 (5 minutes), instances_limit=1
- Resource Node: respawn_time=180000 (3 minutes), instances_limit=3
The default installation forest scene uses: Tree enemies respawn_time=20000, instances_limit=12; mining rocks respawn_time=30000, instances_limit=10.
Related Documentation
- Enemy and Object Respawn Flow - complete setup guide and step-by-step spawn and respawn flow.
- Objects Entity - the respawn area objects, private_params and client_params.
- Create a Room / Map - map layers and the respawn area layer naming.
- Collision Configuration - collision bodies of the spawned objects.
reldens