How to stop an object that slips

Hello,

I want to make a classic mini-game as there is in the Zelda saga.
If the player pushes the block, it can slide on the ice. But I would like it to stop before the edge (so that the block is never blocked by the walls).
How to do? :/

1491231322-capture-d-ecran-2017-04-03-a-20-52-18.png
that depends on how you make it slip - please show us a screenshot of the event pages, then we can tell you where to add what
I don't know if it's the best way, but for slipping, it works.
1491231681-capture-d-ecran-2017-04-03-a-21-00-58.png
If there is not too much going on, simply make empty and invisible events above character on the area outside the ice. Events will block each other unless one of them is through ON. But if the event is above player, the player won't react to it.

However, your event will always create additional lag, simply because the move route never stops. That is why I say "if there is not too much going on" - most computers can handle several such events, but too many and they will lag.
To prevent that lag, you'll need an external event that can switch off that event's movement after it reaches the end of the glide - and that of course can be any position.
Switching off the movement in the correct position will require you to have a six-page (first for standing, four to move in the four directions and one page for resetting to first when it needs to stop) event with one switch for resetting, and one parallel process handling all blocks that can move (for checking their positions)

Or you can try to look for a "slippery tile" plugin, but those have disadvantages depending on what you want to do.
If I create a invisible event, it will block my object, but the player too.
If I create a invisible event, it will block my object, but the player too.
That is where you are wrong - an event will only stop the player is it is on the priority "same as character" - but I said to set to to " above character", that way it will only stop other events
But unfortunately, it doesn't stop other event. So that's why I don't understand.
@Andar Events not passing through other events with "above" or "below" priority was a bug that was fixed in the new version of MV.
Dam! For once a bug would have been useful. ^^

So, I looked for other possibilities but still nothing works. If a charitable soul thinks could help me.;_;
Hey,

there are different ways to handle your situation. The most convenient one might be to install Yanflys Region Restrictions plugin, set a region ID for tiles that events should not be able to pass and border the slippery ice field with this region ID.

Or, if you don't want to use a plugin just for this problem, you can still use region IDs and check them within the event.

First, mark everything the event isn't allowed to cross with a region ID. The border around the ice field AND the obstacles, too!

Spoiler: Like this for example
Reg1.png

Then set up your events conditions, priority, and so.

Spoiler: Something like this
SetUp1.png

If you want to go that route, you basically start a loop in the event which checks if there is (in my example) a tile marked with region ID 1 in front of the event, if not it checks if the other event (here event 2) is in front of this event, if not it makes this event move one tile further and loops again - until there is either a region ID 1 or the other event in the way, in which case it breaks the loop, stopping the event.

Please note to check for region IDs and events BEFORE the movement route, else the player can move the event even after it was stopped previously, allowing the event to leave the icy field.

I picked this setup because I hoped to reduce lag and to bypass problems which otherwise occur when checking if both events are near each other. In this case the event won't be stopped just by passing by, but only if the second event is directly in front of the first one. So there are other methods you can use aswell. It doesn't have to be exactly like my example.

Please also note that I used a little javascript because it's faster for me and doesn't use any variables. But this method can also be done by just using pure eventing (and variables).

Finally, this is my full solution to your problem.

Spoiler: Full Setup
SetUpFull.png
It's wonderful and really exciting!

I'm trying to do all that, but all these code are hard for me. I am really a beginner
Would you have the kindness to send me a project?
I am really sorry, but I can't recopy these codes. Already two days I'm trying and it doesn't work. ;_;
If someone more talented than me can do a new project and send me after, I can give a donation.
In advance a big thank you.
Hey Poupuille,

to be honest, I'd rather like to encourage you to try it on your own. Because for one, you'll most probably encounter many more situation where you'll need to track the x and y coordinates of players and events, and this is also very basic knowledge. It will pay off in the future if you learn those things now. And second, unfortunately I have a pretty slow internet connection and deploying a game with even the minimum of graphics (speaking of just one tileset, nothing else) results in a package of 86MB (unzipped), which would take me very long and probably several attempts to upload.

But of course I see how you may struggle with all the javascript. Sorry, I didn't want to confuse you.

If you like we can try to event that structure. Plus, if you tell me/us where exactly you are struggling with, we can surely help you out.

For an solution that relies purely on eventing, you'd want to start with a loop. Afterwards store the X and Y coordinates of the events in different variables. You can also store the coordinates of the other event you're currently not moving outside of the loop.

Then you need to check which direction the player (or event, because they both will 'look' in the same direction, but some events might have a fixed direction) is looking. You have to add oder substract 1 from either the X/Y coordinates of the moving event, depending on which direction the event faces. This will let you check the tile which lies in front of your event. You can see the X/Y coordinates of the map on the right side of the bottom information bar seen in the map editor. As an example, if your character is facing right, you have to add 1 to the variable where the x value of the moving event is stored.

After you've gone through checking all the directions, you should be able to continue outside of the if structure. Next you'll have to store the region id of the tile in question in a new variable. You'll find the function on the third page of the event editor (Get Location Info...). If the reagion ID variable is Z (the one you've chosen), break the loop, else check if the X/Y variables of the two events are the same (if variable 1 = variable 2), if yes, break the loop - else do nothing. After all that stuff, let the event move one tile away from the player.

And that should already do the trick.

The above suggestion is just a blueprint, as I have not tested/evented it. There might emerge subsequent problems, but it's a start. The preparations won't change. You'll need to mark the border and set the event conditions properly.

Feel free to ask for help, if you have trouble with something. I wish you best of luck 🙂

[Edit] The smart part of me that returned from vacation today suggested that instead of sending a project I could just copy paste the code you need to fill in the if clauses.

Spoiler: Javascripties
$gameMap.regionId($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y + 1) === 1

$gameMap.event(this._eventId).x == $gameMap.event(2).x && $gameMap.event(this._eventId).y == $gameMap.event(2).y -1

-

$gameMap.regionId($gameMap.event(this._eventId).x -1, $gameMap.event(this._eventId).y) === 1

$gameMap.event(this._eventId).x == $gameMap.event(2).x +1 && $gameMap.event(this._eventId).y == $gameMap.event(2).y

-

$gameMap.regionId($gameMap.event(this._eventId).x + 1, $gameMap.event(this._eventId).y) === 1

$gameMap.event(this._eventId).x == $gameMap.event(2).x -1 && $gameMap.event(this._eventId).y == $gameMap.event(2).y

-

$gameMap.regionId($gameMap.event(this._eventId).x, $gameMap.event(this._eventId).y - 1) === 1

$gameMap.event(this._eventId).x == $gameMap.event(2).x && $gameMap.event(this._eventId).y == $gameMap.event(2).y + 1
I'll try this week, I promise!
But I agree with you: I have to try.🙂
I can't find the same construction as on your image.
Here, in the red circle, must be two "end", but impossible.

By the way, tell me if I have the possibility to put my RPG Maker in english, if it can help you.
1491905030-capture-d-ecran-2017-04-11-a-16-02-48.png
By the way, tell me if I have the possibility to put my RPG Maker in english, if it can help you.
You can change the language by placing a file called "locale" (NO .TXT at the end!!!) in the program directory that contains only the letters EN
It's good, I managed to create my event. 😀
Thank you Lestroth !👍

Original thread: https://forums.rpgmakerweb.com/threads/how-to-stop-an-object-that-slips.76792/