After dying I respawn inside a wall, in lava or next to the monster that killed me
The respawn point was fine when you set it, but the world changed. This entry gives your AI a search that starts at the wished spot and spirals outward to the nearest place that is really safe, and says plainly when none exists.
Why this works
Safety is a short list of facts about a cell: room for the body, ground below, no hazard, no enemy near. Checking cells in order of distance finds the closest one that passes all of them, the same way every time.
When not to use it
In a game with fixed bed or checkpoint rules that must not move, show a message and let the player choose instead of moving them silently.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 2 common mistakes and the fix
- 32 lines of example code with 3 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "After dying I respawn inside a wall, in lava or next to the monster that killed me" (read_entry survival-respawn-inside-wall-or-lava) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP