A SOKOBAN puzzle is one where you have to push objects, one step at a time, onto specific locations, and the puzzle is complete when all objects are where they're meant to be. The challenge is to keep yourself free to move, while not moving any objects into a wall or corner where you can't get it out again.
Koi asked for help to create one of these, and as I'm listing the individual steps, figured it might be of interest to others.
This is a sokoban puzzle (image comes from Koi's support thread)
Step 1 - Draw your map
Mark in the walkable areas and borders, and place the destination tiles to indicate the destination for the objects (these must be passable tiles)
Step 2 - Make destination tiles 'special'
You can do this using terrain tags or regions.
To use terrain tags, just go to your Tileset tab, find your 'special' tile, and change its terrain id to something that's not in use elsewhere.
To use region ids, go to the region layer and paint with a single region id over the special tiles.
Step 3 - Add your movable objects
There are a few ways you can set this up.
For something that rolls, you will want Walking Animation checked, but for something that does not have animations or directions, you'll want Walking Animation UNchecked and Direction Fix checked. Leave all the other options UNchecked.
Decide on your trigger - you can either leave it as Action Button, and make the player press space to move it, or just set it to Player Touch, which means just the player moving into it will force it to move.
The event commands are JUST to move the object away from the player (you may or may not want to add a sound effect) - we're not going to do any position checks or puzzle validation here. Make sure you check the Skip if Cannot Move box. It's up to you whether you want to add a Wait for Completion or not.
Make one, verify that it works, and then copy and paste it so all the objects are on their starting positions.
By now, you should be able to set your player position, and walk around pushing the objects in front of you. They should get caught in the corners or on the walls.
Step 4 - Check for puzzle complete
We'll use one "controller" event to monitor what's happening on the map and poll the object locations to see when the puzzle is complete.
It will run as a parallel process, checking every few frames to see where everything is. By default, a parallel process event will run all the commands listed, then will go back to the top and repeat the process, until we do something to tell it to stop.
When the puzzle is complete, it'll display a message and stop any further checks.
At this point, you will want to reward your player for completing the puzzle, and maybe stop them from pushing the objects around any more.
Step 4a - Get first event's X and Y coordinates, and find the terrain tag or region id at that location on the map
Step 4b - Compare with the 'special' terrain tag or region id
If it's not the 'special' terrain tag or region id, this object is not on its final tile and the puzzle is not solved. We don't need to check any more events, so just skip to the end, ready for the next iteration.
Step 4c - Repeat the test for all other movable object events
Copy and paste those lines so there's one group for each event. Then change the event ID in each group, so at the end you're doing the check for each of your movable object events
Step 4d - Success!!!
All objects are on the correct type of tile. Do whatever needs to be done to let the player know they've succeeded, and end the puzzle.
Step 4e - Failure
Just wait a few frames to avoid lag, then by default the event will start running from the top again.
Add your player's starting location in the correct spot, and play away.
Koi asked for help to create one of these, and as I'm listing the individual steps, figured it might be of interest to others.
This is a sokoban puzzle (image comes from Koi's support thread)
Mark in the walkable areas and borders, and place the destination tiles to indicate the destination for the objects (these must be passable tiles)
You can do this using terrain tags or regions.
To use terrain tags, just go to your Tileset tab, find your 'special' tile, and change its terrain id to something that's not in use elsewhere.
To use region ids, go to the region layer and paint with a single region id over the special tiles.
Terrain Tags:
Region IDs:
Region IDs:
There are a few ways you can set this up.
For something that rolls, you will want Walking Animation checked, but for something that does not have animations or directions, you'll want Walking Animation UNchecked and Direction Fix checked. Leave all the other options UNchecked.
Decide on your trigger - you can either leave it as Action Button, and make the player press space to move it, or just set it to Player Touch, which means just the player moving into it will force it to move.
The event commands are JUST to move the object away from the player (you may or may not want to add a sound effect) - we're not going to do any position checks or puzzle validation here. Make sure you check the Skip if Cannot Move box. It's up to you whether you want to add a Wait for Completion or not.
Make one, verify that it works, and then copy and paste it so all the objects are on their starting positions.
Step 4 - Check for puzzle complete
We'll use one "controller" event to monitor what's happening on the map and poll the object locations to see when the puzzle is complete.
It will run as a parallel process, checking every few frames to see where everything is. By default, a parallel process event will run all the commands listed, then will go back to the top and repeat the process, until we do something to tell it to stop.
When the puzzle is complete, it'll display a message and stop any further checks.
At this point, you will want to reward your player for completing the puzzle, and maybe stop them from pushing the objects around any more.
Step 4a - Get first event's X and Y coordinates, and find the terrain tag or region id at that location on the map
If it's not the 'special' terrain tag or region id, this object is not on its final tile and the puzzle is not solved. We don't need to check any more events, so just skip to the end, ready for the next iteration.
Copy and paste those lines so there's one group for each event. Then change the event ID in each group, so at the end you're doing the check for each of your movable object events
All objects are on the correct type of tile. Do whatever needs to be done to let the player know they've succeeded, and end the puzzle.
Just wait a few frames to avoid lag, then by default the event will start running from the top again.
Last edited by a moderator:


