Events triggered by Region ID detection have delayed effects and glitch

Hi.

I have following scenario: Floor is invisible and Player is only allowed to walk on Region ID 1 tiles. If Player walks on Region ID 2 it gets teleported to the start. It's managed by a Parallel Process that recieves Player X/Y through a Parallel Process Common Event.

1st Problem: The detection doesn't work instantly. Means that the Player can still walk on Region ID 2 for a bit until the Event gets triggered. The amount of steps seems to be random. Sometimes it's the first step. Sometimes 5. I also tried to turn the trigger into an Autostart instead of Parallel Process but it doesn't work either. Same with turning the Region ID 2 tiles into Player Touch events doesn't prevent the overstepping but its reaction time seems little better.

2nd Problem: It seems like the system keeps the Region ID longer registered than the Player is on it. After teleporting the Player isn't on Region ID 2 anymore but the Event gets triggered again multiple times. Adding 35 frames of Wait fixes that. I read that other people have other minimum Wait time to prevent this.

The same problem occurs after following a tutorial with the same mechanics I came up with. I uploaded an image of the setup.

Hope there is a solution for it.
Well, the obvious question is - where are you setting that Hero Region ID variable?

It's clearly in a different event for some reason, so these events running at different times would be the cause of your problems.
Well, the obvious question is - where are you setting that Hero Region ID variable?

It's clearly in a different event for some reason, so these events running at different times would be the cause of your problems.
I attached the Common Event managing the X/Ys. I tried out a version where it's handled on the map as a Parallel Process but result is the same.
If you have multiple parallel events running all the time without Wait commands in them, that can also cause lag.

You need to manage parallel events carefully and be efficient.

Is there a strong reason you're constantly monitoring the player's coordinates, region, direction, and whatever else you don't show in that event?

It seems like it would be more efficient to check it just when you need it. For example, set the variable in the event you have in your first post, check it, then put something like a 5 frame wait at the bottom so its not running constantly.

You could make it even more efficient by using a plugin that runs common events by region ID automatically.
I just have 2 Parallel Events running on that Map. For this Puzzle the coordinates have to be checked all time to work or wouldn't a small wait make detection to slow cause of the walking speed.

Is there a strong reason you're constantly monitoring the player's coordinates, region, direction, and whatever else you don't show in that event?

It seems like it would be more efficient to check it just when you need it. For example, set the variable in the event you have in your first post, check it, then put something like a 5 frame wait at the bottom so its not running constantly.
Well I follow a tutorial what uses a Game Manager to control all that stuff. Worked fine so far but you make sound like its not best practice.

I did some brute force debugging and this seems to be the best solution so far (see attachment):

I switch to a new page if Player steps on Region ID 2. Page 2 has Autorun. This version doesn't need any Wait to work against the delay.

Putting Get Location Info seems to be the key. Removing it and getting that information through Common Event makes it glitch. Inside the Map Event and everything is fine. Discovered this by mistake cause I forgot to select it with X and Y detectors. Doesn't make any difference where the player coordinates are set.

Any explanation for this?
Well I follow a tutorial what uses a Game Manager to control all that stuff. Worked fine so far but you make sound like its not best practice.
Definitely not. As a rule, you should not have things running unless you actually need them. And, as I said above, you should almost never have a parallel event running with no Wait command unless you know, per the engine's code, that you need it that way.

I wouldn't even do this with a parallel event - as I said above, I would use a plugin to integrate it into the functions the engine is already doing. But this can work absolutely fine, if you get everything done the right way.

I switch to a new page if Player steps on Region ID 2. Page 2 has Autorun. This version doesn't need any Wait to work against the delay.
That's unnecessary - just put all of those event commands inside the conditional branch on page 1.

I don't understand why you have the Wait 35 at the beginning of the stuff that happens. That means you're waiting over half a second after the player stepped onto the tile to fall - by that time, they could have walked onto another tile already.

I suppose if there's some reason you need that, that's a reason to keep the 2 pages and Autorun...but I should think that looks weird, as a player, to see yourself suddenly stop walking and then fall.

Putting Get Location Info seems to be the key. Removing it and getting that information through Common Event makes it glitch. Any explanation for this?
Because events don't actually happen at the same time. At a fundamental level, nothing can (unless you get into multi-threading with more than one CPU core, which is not the point here).

So at any given point in time, the value that you need to look at in that variable will not necessarily be perfectly in sync if you're getting it from a different event.

Doesn't make any difference where the player coordinates are set.
Well, not for this - you're not checking them at all in this event.
That's unnecessary - just put all of those event commands inside the conditional branch on page 1.

I don't understand why you have the Wait 35 at the beginning of the stuff that happens. That means you're waiting over half a second after the player stepped onto the tile to fall - by that time, they could have walked onto another tile already.

I suppose if there's some reason you need that, that's a reason to keep the 2 pages and Autorun...but I should think that looks weird, as a player, to see yourself suddenly stop walking and then fall.
Without the second page it doesn't stop the player from walking after stepping on Region ID 2 tile. That's only possible if it's triggered by Autorun. At least that's my findings so far.

The Wait 35 (can also be lower) at the beginning has to be there cause otherwise the effects are too fast. The teleport transition already happens before the Player stepped on the tile. Looks wrong without the wait.

Well, not for this - you're not checking them at all in this event.
Hmmm. Your'e right. My bad, again.
Fair enough.

Original thread: https://forums.rpgmakerweb.com/threads/events-triggered-by-region-id-detection-have-delayed-effects-and-glitch.160702/