A standard problem with creating puzzles which require the player to push an object around is that the player may end up pushing it into a position where it is then stuck. Normally the player must then either leave the map or throw a switch to reset everything. This can be frustrating, particularly if several objects have been successfully moved, as the player must now start again from scratch.
This is one of the easiest things to prevent, by creating an object which can be pulled if (and only if) it cannot move forward. It just requires a couple of script calls.
In the example in the screen shot I have used a boulder and the appropriate SE. You, of course, can use whatever you like. As the script calls are too long to show clearly in a screen shot, I will go over them below.
The script call in the conditional branch (tab 4 of the Conditional Branch menu) is this:
e = $game_map.events[@event_id]; e.passable?(e.x, e.y, $game_player.direction)
This is checking if the tile ahead of the object is passable. It works out what “tile ahead” might be by looking at the direction the player is facing.
If it is, then the object moves. If it is not passable, the command goes to the ‘Else’ branch. The script call there is:
$game_player.followers.reverse_each {|actor| actor.move_backward }
Note that this script call is part of a Set Move Route command, for the Player. It takes into account if you have chosen to show the Followers as well as the Player. With this script call, the player and all followers move backwards and the object follows with its own Set Move Route command.
Done.
Variation
Suppose, though, you want the object to be pushed or pulled at the player's choice? For this example I have chosen to set it up so that if the player presses the 'Shift' key while interacting with the boulder, they will 'pull' it, otherwise it will be 'pushed'.
The condition is that the shift button is being pressed. If it is, the Set Move Route for the player begins with the same script call as the first example, that is:
e = $game_map.events[@event_id]; e.passable?(e.x, e.y, $game_player.direction)
The player (plus followers) move backwards, and the object follows them with its own Set Move Route.
If it is not being pressed, the 'Else' condition is just the normal move command for the object.
In both these examples, if you have Followers turned off, then you do not need the script call. You simply set it so that the player moves backwards.
This is one of the easiest things to prevent, by creating an object which can be pulled if (and only if) it cannot move forward. It just requires a couple of script calls.
In the example in the screen shot I have used a boulder and the appropriate SE. You, of course, can use whatever you like. As the script calls are too long to show clearly in a screen shot, I will go over them below.
The script call in the conditional branch (tab 4 of the Conditional Branch menu) is this:
e = $game_map.events[@event_id]; e.passable?(e.x, e.y, $game_player.direction)
This is checking if the tile ahead of the object is passable. It works out what “tile ahead” might be by looking at the direction the player is facing.
If it is, then the object moves. If it is not passable, the command goes to the ‘Else’ branch. The script call there is:
$game_player.followers.reverse_each {|actor| actor.move_backward }
Note that this script call is part of a Set Move Route command, for the Player. It takes into account if you have chosen to show the Followers as well as the Player. With this script call, the player and all followers move backwards and the object follows with its own Set Move Route command.
Done.
Variation
Suppose, though, you want the object to be pushed or pulled at the player's choice? For this example I have chosen to set it up so that if the player presses the 'Shift' key while interacting with the boulder, they will 'pull' it, otherwise it will be 'pushed'.
The condition is that the shift button is being pressed. If it is, the Set Move Route for the player begins with the same script call as the first example, that is:
e = $game_map.events[@event_id]; e.passable?(e.x, e.y, $game_player.direction)
The player (plus followers) move backwards, and the object follows them with its own Set Move Route.
If it is not being pressed, the 'Else' condition is just the normal move command for the object.
In both these examples, if you have Followers turned off, then you do not need the script call. You simply set it so that the player moves backwards.
Last edited by a moderator:


