Check that NPC and Player are Facing the Same Direction

Esjitu

Villager
Member
Joined
Mar 26, 2013
Messages
22
Reaction score
12
First Language
English
Primarily Uses
RMMV
Having a bit of trouble creating an event where, if you approach an NPC face-to-face, they talk normally, but if you approach them from the side or behind, you pickpocket them.

The way I thought to set it up was to have a bunch of conditional branches to check that the NPC and player are facing the same direction - so if the NPC is facing down, check if the player is facing up, do X. Else, do Y. Then check if the NPC is facing up, and again that the player is facing down, and so on. I made a similar multi-check event before with a bunch of nested conditionals in this way (though for that it was checking for switches) so this SHOULD work, even if it looks a bit messy.

The problem is, when you interact with the NPC, of course he turns to face the player...so it'll always see that the NPC and player are facing the same direction. Of course this could be fixed by turning direction fix on, but I want the NPC to be able to walk around normally until the player interacts with them, THEN have it check if they're facing the same direction before deciding the action.

What's the best way to go about this? I tried a few different things with move routes and self-switches but I couldn't get anything to work the way I want it to. Ex. I can't have the first action be a move route with direction fix, because the NPC will already be facing the player just by talking to them. I would like the NPC to be able to move around normally with autonomous movement (which means setting the event to direction fix won't work) but when you interact it should check that they're facing the same direction. I can't think of a way to do that without the event being set to direction fix by default...but then I can't get the NPC to move and walk around like a normal person.

Is this possible and I'm just missing something, or is there no way to do this without just making the NPC static so you always know what direction they'll be facing when the player approaches?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,068
Reaction score
6,698
First Language
German
Primarily Uses
RMMV
that is what the direction fix option is for - it prevents the event from changing direction toward the player when interacting.

If that NPC walks around, you need to disable it before each move command and reactivate it after the move. You do that in the move route settings, there is a command for that there.
 

Esjitu

Villager
Member
Joined
Mar 26, 2013
Messages
22
Reaction score
12
First Language
English
Primarily Uses
RMMV
So I'd set the autonomous movement to a custom move route (instead of, say, random) and do something like:

direction fix off
move left
direction fix on
direction fix off
move down
direction fix on

etc? Is that what you mean?
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
29,068
Reaction score
6,698
First Language
German
Primarily Uses
RMMV
yes, exactly - you can even set the custom autonomous route to random, or if that event is controlled by another one use the set move route command in the same way.
 

Esjitu

Villager
Member
Joined
Mar 26, 2013
Messages
22
Reaction score
12
First Language
English
Primarily Uses
RMMV
It doesn't seem to be working for me. I set up a test actor with the following:




When I talk to him, he still turns to face me.
 

dsiver144

Peaceful Days Dev
Veteran
Joined
Sep 19, 2013
Messages
260
Reaction score
804
First Language
Vietnamese
Primarily Uses
RMVXA
After using Shaz no lock script. You can make that this way to check if player and event are facing face-to-face:
Using this script line in Conditional Branch: $game_map.events[@event_id].direction == 10 - $game_player.direction
 
Last edited:

Esjitu

Villager
Member
Joined
Mar 26, 2013
Messages
22
Reaction score
12
First Language
English
Primarily Uses
RMMV
I used a bunch of nested conditional branches, but that sounds much more efficient!!

I got the no lock script set up and with that + the above-mentioned direction fix-toggling move route everything seems to be working as intended now. Thanks to everyone for the help!!
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

I feel like it's about time I share all the result of my experiment project here. But there's a lot of it.
Me and brother have an ongoing rivalry. We constantly fight for the High Score in Galaga on our arcade cabinet. Today I take back the top with 239,000. He'll be back. (No-Fire glitch is banned)
Made Custom ENEMY Information Screen
I'm having such a hard time thinking of an interesting battle system. and not being a coder, certain things I wanna do seem a lot harder lol.
Created a character outline with some code. I have no use for this. I'm....bored.....

Forum statistics

Threads
93,721
Messages
914,920
Members
123,324
Latest member
ahmbor
Top