Help with pushing and pulling objects

Sword_of_Dusk

Keyblade Master
Veteran
Joined
Sep 13, 2015
Messages
247
Reaction score
290
First Language
English
Primarily Uses
RMMV
I have a simple problem. I know how to set up an event to push something like a boulder around. But how do I also have it to where you can pull it instead, such as if the object is placed in a corner?
 

Rubescen

Veteran
Veteran
Joined
Jan 4, 2016
Messages
148
Reaction score
150
First Language
English
Primarily Uses
RMMV
To be honest, this isn't the simplest problem given the way interactions with objects are treated (it's much easier to set up a push than pull, imo).

In any case here is an inelegant though functional solution using only basic eventing that might help you get started on the problem. To make it more intuitive for players it needs some tweaking.

1598242656341.png
 

Quexp

Lifelong Learner
Veteran
Joined
Jun 18, 2018
Messages
124
Reaction score
246
First Language
English
Primarily Uses
RMMV
Too bad we can't set a Conditional Branch for when an Event can't move (or can we?). There should be some kind of workaround where you can give the player the option of resetting the puzzle. Easiest way might be just have it near a map transfer point where the and exit and re-enter to start over.

Or, if too far from a transfer point, have a nearby switch that resets it?

Unless...MZ lets Events overlap (either native or via plug-in). Then you could give a pull option if the Event touches an invisible switch that would let the player pull the boulder/object. I don't know, I'm just throwing out what comes to mind.

EDIT: I found this and think it'll help!
 
Last edited:

Sword_of_Dusk

Keyblade Master
Veteran
Joined
Sep 13, 2015
Messages
247
Reaction score
290
First Language
English
Primarily Uses
RMMV
I can easily reset the event's position, but if I could figure out how to pull an object, it would be a little more. . .realistic, I guess.
 
Joined
Aug 21, 2020
Messages
47
Reaction score
37
First Language
Spanish
Primarily Uses
N/A
Try this:

1.- Make a common event (lets call it "Grab") that start via switch, whatever switch (Switch 1). Make it run on parallel.

2.- Conditional branch -> Page 4 -> Button "Ok" is "pressed being pressed".
Yes? = Activate Switch (Switch 20, lets call it "Pull"). Else? = Put switch 20 OFF.

Captura de pantalla (48).png

3.- Create your event in the map. It will have two pages.

Page 1 (Push):
Captura de pantalla (51).png

Captura de pantalla (52).png

Page 2 (Pull):
Captura de pantalla (53).png
Thanks to the common event, the event page will change when you press the A button, and when you interact with the object, it will make it move to wherever you want it to move.
This can be done better, of course, but is 12:30 am where I leave, sorry if I can't do more haha.

Good luck!
 

Attachments

Last edited:

Quexp

Lifelong Learner
Veteran
Joined
Jun 18, 2018
Messages
124
Reaction score
246
First Language
English
Primarily Uses
RMMV
The brainstorming on this is a lot of fun. Going off of @DisfantasyProject's idea, how about this?

push_pull.png

The only snag is how/when to tell the Event to shut off the Move switch.

EDIT: I just realized I still have Directional Fix commands in there we won't need them if pulling the image from a tileset.
 
Last edited:

Rubescen

Veteran
Veteran
Joined
Jan 4, 2016
Messages
148
Reaction score
150
First Language
English
Primarily Uses
RMMV
@Quexp @DisfantasyProject

As far as I can tell from your examples, they are just more complicated versions of what I posted in my first reply (which does this in one conditional on one page). I can't tell what you are gaining by adding the switches, unless I'm missing something?

The problem with my solution is that it feels a bit unintuitive to press left (while holding dash in my case) run into something, and then have it move right while you're still holding left down. But I think your versions end up the same?
 

Sword_of_Dusk

Keyblade Master
Veteran
Joined
Sep 13, 2015
Messages
247
Reaction score
290
First Language
English
Primarily Uses
RMMV
I was up late last night trying to hammer out a solution of my own as well. Hit a snag, sadly. Gonna give my idea another go over, as well as use what you guys have posted. If we somehow come up with a way to make it work smoothly, it'd be a big aid to most devs.
 
Joined
Aug 21, 2020
Messages
47
Reaction score
37
First Language
Spanish
Primarily Uses
N/A
@Rubescen Leaving aside if your way of doing it being intuitive for the player or not, I think both your way and my way are correct, it just depends of how much the developer wants to do with said event.

Doing it with switches allow it so you can decide when to stop the event for being able to be moved around. For example, pushing a box over a interruptor or until it makes that nice bridge you need to pass over a river or something.

Page 1 of my event is made that way just for aesthetic purposes, to make it look like the object is being pushed instead of kicked away.

And there is a little bug that happens your way for pulling. If you corner yourself against a walk and pull the object again, the object will mover over your character. Thats why I put a delay of 10 frames, to let the game check for collisions first.

All in all, as I said, both ways are good, each for their own reason.

Regards!
 

Rubescen

Veteran
Veteran
Joined
Jan 4, 2016
Messages
148
Reaction score
150
First Language
English
Primarily Uses
RMMV
Definitely. Your version works, I just wasn't sure what was gained by the switch and such. Not a bad thing to have more variations, I just wanted to clarify if you were getting different results with your setup from mine. I can see how the switches/common event could add more functionality.

And there is a little bug that happens your way for pulling. If you corner yourself against a walk and pull the object again, the object will mover over your character.
That was actually intentional, I preferred the smoother movement and ability to pull something into a corner. But Yeah. Removing the through and adding a wait, prevents that.

I think the only way to make this more smooth/natural using eventing only is through some parallel x,y checks. Might try to play with that later.
 

1Mustadio1

BromanLegion
Veteran
Joined
Jan 19, 2016
Messages
31
Reaction score
58
First Language
English
Primarily Uses
RMMZ
You could line the walls with copies of a single event that change the interaction on the boulder to step back instead of stepping forward. Would be pretty easy to do that with a simple switch.
 

1Mustadio1

BromanLegion
Veteran
Joined
Jan 19, 2016
Messages
31
Reaction score
58
First Language
English
Primarily Uses
RMMZ
Although. The simplest solution would be to have the event show two choices. Push. Pull. "Push or Pull?" Then, depending on choice, have the event behave accordingly. It's not as "real time interactive" as some of the more complicated solutions but it solves the problem of having the boulder getting stuck on walls lol.
 

Quexp

Lifelong Learner
Veteran
Joined
Jun 18, 2018
Messages
124
Reaction score
246
First Language
English
Primarily Uses
RMMV
@Rubescen - true, everything here allows the item to be pulled but sharing different ideas sometimes spurs a good solution. Using @DisfantasyProject's switch idea is just because I'm assuming the player wants to push the item except for when stuck.

My idea combining the previously mentioned isn't the best either (as the event and player don't move simultaneously) but thought I'd share what I tried. Going back to my switch use, that would only help if there was a good way to shut it off at the right time.

@1Mustadio1 - I like that idea! I was like, "Too bad Events can't overlap." but I didn't even think of using the walls.
 

Rubescen

Veteran
Veteran
Joined
Jan 4, 2016
Messages
148
Reaction score
150
First Language
English
Primarily Uses
RMMV
Ok. Here's another solution that's a bit more complex. It's more intuitive (i.e. you press ok on the boulder to trigger push/pull, and then push/pull by pressing the direction key as you'd like to move). The graphic timing is a bit sluggish (though that could probably be tweaked to look better).

Event page one is a super simple setup to trigger the parallel page 2 (you could use an actual switch instead of the self, if that suits your purpose better):
1598305924860.png

Event Page Two runs a parallel loop that check the player's relation to the event and pushes/pulls according to the input. There are several conditions set to break the loop (if the player releases the enter button/ if the player moves away from the event / if the player presses two directions at the same time (this is to help limit the glitchiness of the system).

1598307069420.png
Here's the scripts that got cut off (since it's cut off)

JavaScript:
$gameMap.event(this._eventId).x - 2 <= $gamePlayer.x && $gameMap.event(this._eventId).y === $gamePlayer.y && Input.isLongPressed('left') //Pull
$gameMap.event(this._eventId).x - 1 === $gamePlayer.x && $gameMap.event(this._eventId).y === $gamePlayer.y && Input.isPressed('right') // Push

//prevent button mash
Input.isPressed('left') && Input.isPressed('right') || Input.isPressed('left') && Input.isPressed('down') || Input.isPressed('left') && Input.isPressed('up') || Input.isPressed('right') && Input.isPressed('down') || Input.isPressed('right') && Input.isPressed('up') || Input.isPressed('up') && Input.isPressed('down')

//cancel if out of range
$gameMap.event(this._eventId).x !== $gamePlayer.x && $gameMap.event(this._eventId).y !== $gamePlayer.y
You just need to duplicate the push/pull for the Up & Down (Y-axis), and Right (X-axis), adjusting the x,y and button input as necessary.

This is stretching the idea of "eventing" with all the script calls, but you can basically do the same thing just using more nested conditionals instead. It's just a lot easier to do it with the && and ||. Considering how long this takes to setup, I'm not sure this is really a better solution than the above versions, but it's solved my frustration about pulling right while holding left! :D
 

PauloHPBender

Delirious Storyteller
Veteran
Joined
Oct 16, 2015
Messages
92
Reaction score
22
First Language
Portuguese
Primarily Uses
N/A
To be honest, this isn't the simplest problem given the way interactions with objects are treated (it's much easier to set up a push than pull, imo).

In any case here is an inelegant though functional solution using only basic eventing that might help you get started on the problem. To make it more intuitive for players it needs some tweaking.

This is a bit offtopic, but are you using Shift as a "alternative interaction"? This is quite ingenious! I might make a "interact/inspect system with this! Thans a LOT for the idea!
 

Quexp

Lifelong Learner
Veteran
Joined
Jun 18, 2018
Messages
124
Reaction score
246
First Language
English
Primarily Uses
RMMV
I'm not on my PC now, so no screenshot, but I like the pull object idea so ended up figuring out what works for me. I have a Conditional Branch set where it pushes if the player touches it but a Show Choices push/pull option pops up if player uses the Action Button. I still might mess around with using walls like @1Mustadio1 suggested though.

This has been a fun thread. Thanks for letting me tag along!
 
Last edited:

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

Latest Threads

Latest Posts

Latest Profile Posts



I've been experimenting with improved memory management again, which allowed me to include items to increase player path length. These are both 44 grid spaces long, and stable. :LZSexcite:
I FINALLY DID IT! 5 years making my very first game and I just officially released it on STEAM..... OMG..... I can say I finished a game! The feelings!!!!!
Stream will be live shortly! I am going to be playing some Among Us! Feel free to drop by!
Ami
tv program always get the ratings (it's the reason why drama series has 1000+ episode),also full and nonsense of censorship (weird blur, a scene getting cut because the unconvenient viewer,but it unconvenient to me either. you never see what the original is)

i know the reason is to take cover the viewer from the negative thing,but i just laughing and mocking of them that they're always suck :guffaw:
Star Chart Idea - Just something I am working on.

Forum statistics

Threads
104,460
Messages
1,006,444
Members
135,966
Latest member
Kleik
Top