Ultra-easy creation of Push-Pull object

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited by a moderator:

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
This looks interesting, but i somehow have the feeling this could be exploited in puzzles.


But i realy like the follower stuff.


But if you dont mind here is the Idea i had some time ago.


I placed region 2 around the map boarders, and as soon the rock gets there and the player moves away, the rock rolls back one tile.

rock-1.PNGrock-2.PNG
 
Last edited by a moderator:

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
@Bex Yes, it is precisely with puzzles of varying complexity in mind that I did this.


Thanks for your alternative suggestion, but my objective was to make the creation of these objects as simple and straightforward as possible.  I did not want to use regions or other complicating factors - particularly regions such as region 2 which is used as default in a number of scripts affecting regions.


I wonder if you would mind putting your images inside spoilers, as they are not directly relevant to my tutorial, and I would rather that other Members didn't start using this thread to make comments/ask queries about something else.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,492
Reaction score
408
First Language
German
Primarily Uses
RMMV
No problem, and yes my sugestion would still need the buton for resseting.


Thats why i like your aproach. Thanks for the Tutorial.
 
  • Like
Reactions: Kes

Marquise*

Veteran
Veteran
Joined
Jul 9, 2014
Messages
4,942
Reaction score
8,248
First Language
French-Canadian
I should pin this somewhere :D
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,867
Messages
1,017,061
Members
137,575
Latest member
akekaphol101
Top