Display Image Based on Character Orientation

Sophitia

Veteran
Veteran
Joined
Feb 13, 2014
Messages
42
Reaction score
11
First Language
English
Primarily Uses
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
 

GmOcean

Veteran
Veteran
Joined
Nov 29, 2020
Messages
111
Reaction score
91
First Language
English
Primarily Uses
RMMZ
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.
 

Sophitia

Veteran
Veteran
Joined
Feb 13, 2014
Messages
42
Reaction score
11
First Language
English
Primarily Uses
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. :rswt
 

Nolonar

Veteran
Veteran
Joined
Feb 18, 2018
Messages
390
Reaction score
545
First Language
French, German
Primarily Uses
RMMZ
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.
 

Latest Threads

Latest Profile Posts

What happens with this list, is it currently possible to buy any of these RPGMAKER at least those that are for PC?

Combat skill combination demostration
grief... finding a font that works with the engine has been a bigger process than I thought it'd be. doesn't help MV loves to scrunch letters next to each other like a football huddle.
The new Phoenix plugin. I drew icons and an interface into it

Forum statistics

Threads
122,182
Messages
1,147,088
Members
160,455
Latest member
fajar82
Top