Arrow Indicator Overhead of Player Causing Lag

My game has secret paths that can be taken in various parts of the game, and to help navigate, I wanted an arrow indicator above the party leader's head. It looks like this:
1691705165399.png

The arrow follows the party leader so long as they are on a specifically numbered region. To accomplish this, I used to the following code:

1691705360200.png

This is set to "Parallel," and so it only detects if a player is in the region specified (in this case, Region 1).

The problem is that I noticed a very tiny instance of lag as I would first enter into a region that triggered this indicator. After it was triggered, it all ran smoothly. The play testers have told me they have far worse problems. One of them has a slower system than mine, and his lags (i.e. game freezes) for about 5 seconds before it will let him continue. The other play tester has an older laptop, and his completely locks up the game when triggering the indicator, and he cannot continue to play.

Does anyone know of a way to fix this problem, or perhaps another way to approach it? Please keep in mind that I need to use a picture, not an icon, because the picture will appear above the parallax layers I'm using, but the icon will not.

Thank you for your time; any suggestions are welcome.
first, please give a full screenshot next time including the properties.

second, the parallel is missing the wait command. without the wait command, the arror is placed sixty times per second again and again - that is what causes lag.

you'll have to experiment which number of waits is the best however - too many and the arrow will not be updated fast enoug, too few and the lag will be there.
wait(10) might be a good compromise for something like this
Apart from the wait time that Andar mentions, I noticed some other things:
  1. Why are you setting the "POSITION" variables after showing the picture? 😅

  2. You could move the Get Location Info command inside the first branch.

  3. Typically you'd use Show Picture when entering that region, then Move Picture to update its location. Move Picture also has interpolation options for smooth movement over a duration, e.g. move over 10 frames + wait 10 frames.

    You could track the "previous region" with another variable, then:
    • If the region is now 1:
      • If the region was not 1 before: Show Picture.
      • Else: Move Picture.
    • Else, if the region was 1 before: Erase Picture.
    Then set the "previous region" variable equal to the current region at the end of the event.

    Alternatively, there are plugins like RegionBase (ships with MZ: <install folder>/dlc/BasicResources/plugins/official) that can trigger events or toggle a switch when you enter/leave a region.
(MZ culls its image cache on map transfer, and the picture name isn't changing, so it shouldn't be a file load delay.)

If you're using any plugins, they might be contributing to this "lag", depending on what they do.
first, please give a full screenshot next time including the properties.

second, the parallel is missing the wait command. without the wait command, the arror is placed sixty times per second again and again - that is what causes lag.

you'll have to experiment which number of waits is the best however - too many and the arrow will not be updated fast enoug, too few and the lag will be there.
wait(10) might be a good compromise for something like this
Hello, and thank you for your time. I did not give a full screen shot because there is literally nothing else selected on the properties. The only difference is that I selected "parallel."

The wait command causes the arrow to jump, and makes the movement confusing, which is why I did not use wait. I figured this might lead to a problem, but I wasn't sure how to fix it. Thank you for those suggestions.

Apart from the wait time that Andar mentions, I noticed some other things:
  1. Why are you setting the "POSITION" variables after showing the picture? 😅

  2. You could move the Get Location Info command inside the first branch.

  3. Typically you'd use Show Picture when entering that region, then Move Picture to update its location. Move Picture also has interpolation options for smooth movement over a duration, e.g. move over 10 frames + wait 10 frames.

    You could track the "previous region" with another variable, then:
    • If the region is now 1:
      • If the region was not 1 before: Show Picture.
      • Else: Move Picture.
    • Else, if the region was 1 before: Erase Picture.
    Then set the "previous region" variable equal to the current region at the end of the event.

    Alternatively, there are plugins like RegionBase (ships with MZ: <install folder>/dlc/BasicResources/plugins/official) that can trigger events or toggle a switch when you enter/leave a region.
(MZ culls its image cache on map transfer, and the picture name isn't changing, so it shouldn't be a file load delay.)

If you're using any plugins, they might be contributing to this "lag", depending on what they do.
1. Frankly, I thought I had to do it that way (because I've had lots of problems with the "Show Picture" function), but now that you mention it, it would be better to set the show picture after the coordinates.

2. I went ahead and fixed that to your specifications, but the "VIEW MAP" switch I have on there has no bearing on this feature. It was simply to prevent a bug occurring on a different feature I have in the game that uses "Show Picture" from conflicting with this one.

3. That is an idea I hadn't thought of. If I am going to do it that way, then it might be better that I use Visustella's MoveEvents for On-Touch Region. However, that presents a problem that perhaps I don't understand (because I'm not that good with scripting)... how do I check if the region was NOT 1 beforehand? I don't see any option like that. As soon as the player steps on a region, it's setting the Variable (REGIONPlayerLocation) to 1, and if the player steps off the region, it does not trigger the event, so it will remain as 1.
You could track the "previous region" with another variable
But the problem is that it would require another parallel process that would have to continually update the variable of the player position at all times. Wouldn't that cause even more lag? Furthermore, I would have to include a separate parallel event in every map to find that information.

I appreciate all the advice so far. It's slowly helping me understand. Perhaps I will have to have that parallel region detector to make this work, but it doesn't sound like the right solution. I'm playing with it and trying to find a way around it, but nothing's coming to me so far.
The wait command causes the arrow to jump, and makes the movement confusing, which is why I did not use wait
Then you have used too many waits in that case - as I said you need to experiment to find the correct wait number for each case. Ten was a guess, if that causes jumping then try 4 waitframes
But the problem is that it would require another parallel process that would have to continually update the variable of the player position at all times
no, it would be the same parallel process as above where that variable is updated.
one parallel process can keep hundreds of variables updated if you would need that many.
Parallel without wait is running every frame, which will lag the game heavily on some PCs, as one of your testers found out with the lockup. You will want a wait at some point in it. May need to play with it to see what wait value to use. In fact you might be able to set it up to run only when it needs to update as the picture will stay on screen until you erase it otherwise.

I wonder if you could set it to only run when you take a step or something?
"Lag" in this context is typically a visual indicator of resource scarcity: the game is struggling to do 1 frame of work within 1 frame of time, because there is too much work for its resources (CPU, GPU, RAM, etc) to handle. Work stacks up...e.g. if you're using a lot of plugins that implement resource-expensive features (screen filters/lighting is a common one), then you can expect to see frame drops sooner or later. That's why it can be worth checking your plugins and removing/replacing the ones that you don't need.

Of course, you can also overwork the system with no plugins at all, but that's generally easier to diagnose and fix. If you have any other Parallel events in your game, do consider those as well. As Andar has said, most Parallel events do not need to run every frame.

the "VIEW MAP" switch I have on there has no bearing on this feature. It was simply to prevent a bug occurring on a different feature I have in the game that uses "Show Picture" from conflicting with this one.
Yes, I had guessed as much. I mentioned it mainly to introduce the logic: there is no point getting the region ID if you're not going to check it. Skipping things like that forms a big part of "optimisation", even if this particular case is unlikely to have any notable effect.

it might be better that I use Visustella's MoveEvents for On-Touch Region. However, that presents a problem that perhaps I don't understand (because I'm not that good with scripting)... how do I check if the region was NOT 1 beforehand? I don't see any option like that.
😅 If VisuStella's plugin does not offer an appropriate feature set, then why would you use it? I suggested an appropriate plugin, if you want to try that approach instead of your Parallel event.

For a "once per step" update like bgillisp suggests, you could consider an evented approach by counting steps, e.g. I dug up this old post of mine:
Alternatively, one of VisuStella's plugins may have a "trigger event on step" kind of feature? I have a plugin called Cae_AutoSwitchVars (link to thread) that amongst other things lets you turn on a switch every step. There are probably several other options.

But the problem is that it would require another parallel process that would have to continually update the variable of the player position at all times.
Like Andar says, and like I suggested, you can use one event for both:
Then set the "previous region" variable equal to the current region at the end of the event.
👋
If your arrow is jumping when using show picture and waits, you could also try showing it with an animation on the player? An animation follows the player automatically and smoothly.
if you're using a lot of plugins that implement resource-expensive features

If VisuStella's plugin does not offer an appropriate feature set, then why would you use it?
If performance is a huge concern to the OP, I would also not recommend using VS plugins. There are likely alternatives that are lighter weight in performance for what wants to be accomplished here. I would only use VS plugins if you plan on taking full advantage of their feature set and using those features regularly throughout the game.
I apologize that it took so long to get back with all of you on this. I was waiting for my game testers to test it on their systems, and I had to wait two weeks before any of them would try out my new changes. (Don't ask me why it took that long, I still don't know.)

I did end up fixing it, although there was no way I could find to fix it using the VS plugin as suggested above. I could not figure out how to get it to recognize non-region spaces.

What I did do was use a common event on the map itself, as I had setup previously, but I used the MOVE picture option. For anyone trying this in the future, the trick I found to be most effective was waiting 4 frames (as suggested above) and then moving the picture over 5 frames, which will give it the smooth movement without lagging the game.

Here's my setup, just call a common event, and set the map event on parallel:

1693091818240.png


Hope that helps someone else. Thanks for the help everyone! 🙂
I could not figure out how to get it to recognize non-region spaces.
Get Location Info -> Region ID -> Player

Conditional Branch -> Variable from Get Location Info command == 0

Original thread: https://forums.rpgmakerweb.com/threads/arrow-indicator-overhead-of-player-causing-lag.160196/