Display Image Based on Character Orientation

So, to simulate a first person view using images I'm having players walk on a tile, which brings up the image. The image varies depending on which direction the character is facing, obviously. In this example up and down are a forest path. Left and right are impassible trees.

Because the player is able to rotate in place, the event needs to be checked and updated without leaving and touching the tile again. As such, would the loop command as used in the below code be the best option for me? It seems to make things very sluggish (which is not surprising, being an infinite loop) but I'm not sure what would be better suited.


Code:
◆Loop
  ◆Control Variables:#0001 CharOrientation = Direction of Player
  ◆If:CharOrientation = 8
    ◆Plugin Command:VisuMZ_4_ProximityCompass, Compass: Change Player Icon
    :              :Icon Index = 90
    ◆Show Picture:#1, forest, Center (640,260), (100%,100%), 255, Normal
    ◆
  :Else
    ◆If:CharOrientation = 4
      ◆Plugin Command:VisuMZ_4_ProximityCompass, Compass: Change Player Icon
      :              :Icon Index = 92
      ◆Show Picture:#1, Forest Wall, Center (640,260), (100%,100%), 255, Normal
      ◆
    :Else
      ◆If:CharOrientation = 6
        ◆Plugin Command:VisuMZ_4_ProximityCompass, Compass: Change Player Icon
        :              :Icon Index = 93
        ◆Show Picture:#1, Forest Wall, Center (640,260), (100%,100%), 255, Normal
        ◆
      :Else
        ◆If:CharOrientation = 2
          ◆Plugin Command:VisuMZ_4_ProximityCompass, Compass: Change Player Icon
          :              :Icon Index = 91
          ◆Show Picture:#1, forest, Center (640,260), (100%,100%), 255, Normal
          ◆
        :Else
          ◆
        :End
        ◆
      :End
      ◆
    :End
    ◆
  :End
  ◆
:Repeat Above
Since the Event is technically an infinite loop, once activated it will go on forever and ever even if you leave that tile, because the loop is still going.

You need to do 2 things.
1. Add a check to make sure that the player is still standing on that tile. If they are, continue the loop as normal, if they are not, then break the loop, letting the event end. (This is important because if you had 3 of these events and you walked on all 3 tiles, you could end up with images just being thrown all over the place endlessly).

2. Right now your loop is checking 60*4x/second (240 checks every second). That's a lot. Adding a wait command of lets say, Wait 5, reduces that to 12*4x/second (60 total checks per second). May not seem like much, but remember, as your project grows in size, you may have other things going on at the same time. It all adds up, so attention to detail now helps in the long run.

These 2 things should increase performance quite a bit and let you end the infinite loop when you step off of the tile.
Silly, but I didn't even think of it always checking when you step off the tile, because the original issue I had was making it recognize the action more than once after stepping on the tile. So thanks again for that!

And you're so right that attention to detail now helps big time in the long run. I've no desire to run back and add wait commands to a few thousand events months down the line. 😅
Don't forget that when the character is facing up, and the player presses right, the character will move right, thereby leaving the tile.

If you have a plugin that changes that behavior, that's great. Otherwise you'll need to event it.

This is as simple as checking if the player is pressing right, and if the character is also facing right, move them to the right, otherwise make them turn right instead. Same thing for the other 3 directions.

Original thread: https://forums.rpgmakerweb.com/threads/display-image-based-on-character-orientation.144292/