RMMV Event trigger when player STOPS touching event?

How do I trigger an event to happen when the player STOPS touching the event? I want to do an event that triggers automatic doors that will close when the player moves away from/stops touching the door trigger.
You would have to turn a switch on when the player touches it, have it switch over to a parallel event page that checks every x frames whether the player is still touching it and if not, do what you want to happen and switch back off to the first page.
You can make invisible player touch events around the door that close it, e.g. but flipping a switch.
Both ways could work, but putting the invisible events two tiles away from the doorway that close it again would be a bit more efficient than having a parallel event.
Here's what I went with lol
1732745888891.png

1732745918787.png
you can do it with region too, and open for 2-3 seconds,
than after 120-180 frames it closes.

player distance can also work out, but there was a plugin that did
this exactly what you want while facing the event.

I have that plugin somewhere and works nicely, but I forgot it's name
as it's easy to setup.

you can do this also with 1 page alone, so no need for 2 pages.
Going this route, I would use a wait command of at least 1 frame (preferably around 8-16 frames since you are dealing with movement, scale to fit your needs) so it is not constantly checking for the player position.

Also, since .pos() returns true/false, you can just do
Code:
!$gamePlayer.pos(14, 4)
in the script portion of the conditional branch.
Going this route, I would use a wait command of at least 1 frame (preferably around 8-16 frames since you are dealing with movement, scale to fit your needs) so it is not constantly checking for the player position.

Also, since .pos() returns true/false, you can just do
Code:
!$gamePlayer.pos(14, 4)
in the script portion of the conditional branch.
Ah thanks. I couldn't figure out where to put the ! so I just defaulted to having it match values instead. Seems to be working okay without a wait time, might be because I set a 2nd event to trigger the door open event so both events are inactive while the player isn't near them.
Seems to be working okay without a wait time
Yes, it will work fine. The point is that you should be in the habit of never making a parallel process without an appropriate Wait time built into it, unless it's something that needs to be running every frame - and this doesn't.
Yes, it will work fine. The point is that you should be in the habit of never making a parallel process without an appropriate Wait time built into it, unless it's something that needs to be running every frame - and this doesn't.
Ohh okay okay I get what you mean, thanks
It'll work, the issue is it contributes to lag when it doesn't need to. Add some more parallel events firing off 60 times a second with no waits and you'll see your framerate drop.
It'll work, the issue is it contributes to lag when it doesn't need to. Add some more parallel events firing off 60 times a second with no waits and you'll see your framerate drop.
And it's for this reason why Turan had said:
putting the invisible events two tiles away from the doorway that close it again would be a bit more efficient than having a parallel event.



Ideally, you shouldn't be putting things in parallel events unless it's necessary. If there is a better way to do something without a parallel event, then I would recommend going that way every time.
Honestly it's not going to be an issue unless you have it running without waits. It's also only parallel in the short time frame of the player touching it to moving a tile away.

Original thread: https://forums.rpgmakerweb.com/threads/rmmv-event-trigger-when-player-stops-touching-event.173493/