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?
Help with pushing and pulling objects
RPG Maker MZ SupportTo 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.
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.
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!
forums.rpgmakerweb.com
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!
Making A Pushable and Pullable Barrel
Here is the code which was the most successful: ◆Show Choices:Push, Pull (Window, Right, #1, #2) :When Push ◆Play SE:Equip2 (90, 60, 0) ◆Set Movement Route:This Event (Skip) : :◇Move away from Player ◆Set Movement Route:Player (Skip, Wait) : :◇1 Step...
forums.rpgmakerweb.com
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.
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.
3.- Create your event in the map. It will have two pages.
Page 1 (Push):
Page 2 (Pull):
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.
Good luck!
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.
3.- Create your event in the map. It will have two pages.
Page 1 (Push):
Page 2 (Pull):
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!
The brainstorming on this is a lot of fun. Going off of @DisfantasyProject's idea, how about this?
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.
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.
@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?
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?
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.
@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!
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!
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.
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.
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.
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.
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.
@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.
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.
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).
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! 😀
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):
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).
Here's the scripts that got cut off (since it's cut off)
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.
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).
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! 😀
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!
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!
This has been a fun thread. Thanks for letting me tag along!
Original thread: https://forums.rpgmakerweb.com/threads/help-with-pushing-and-pulling-objects.125908/