How to Make an Event Detect Player Proximity

Fufi_Saintz

Veteran
Veteran
Joined
May 14, 2020
Messages
79
Reaction score
30
First Language
Italian
Primarily Uses
RMMZ
Hi everyone, hope you all are well!

I just stepped into this thread because I am trying to make the same thing in my game, only with a difference: I want the player to be detectable only when a rotating/moving enemy is facing towards him/her (stealth part of the game, of course).
I already tried some solutions, and got some nice-but-not-exactly-what-I-wanted results, but they are complex solutions with a lot of switching/eventing, so I would be glad to hear your suggestions on how to achieve that result easily (or at least: "more easily", sure you all have got better solutions).

Heve a good day!
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,611
Reaction score
3,717
First Language
EN
Primarily Uses
RMMZ

I've split your post into its own thread, from here:

As you've mentioned, your request is different. You are always welcome to link to other threads that are relevant, like I've done here. :kaohi:

To check facing direction, you can use:
  • Conditional Branch -> Character ___ is facing ___; or
  • Control Variables -> Game Data -> Character -> Direction.
The latter returns a numpad direction: 2 = down, 4 = left, 6 = right, 8 = up.

This allows you to check both proximity (as discussed in the linked thread) and "field of view". E.g. if facing left, a 180-degree FoV check could be "is player X <= this character's X?". You can do other angles with some maths.

If you want to do line-of-sight checks, that's considerably more complicated. Without a plugin, you can use regions to help identify "sight areas", e.g. a room that is mostly region 1, but the area visible from the corridor is region 2; the corridor is all region 2. If you want movable LoS obstacles, though, then I'd definitely suggest a plugin.
 

AquaEcho

Script Kitty
Veteran
Joined
Sep 20, 2021
Messages
532
Reaction score
245
First Language
English
Primarily Uses
RMMV
You can try Krons AI base
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,940
Reaction score
750
First Language
German
Primarily Uses
RMMZ
Here an Example to get started...

Var1 set to Event Direction (2,4,6,8)
Var2 set to Player MapX
Var2 - Event MapX
Var3 set to Player MapY
Var3 - Event MapY

If Var1 = 2 (Down)
If Var3 is equal or more 0
If Var3 is equal or less 6
If Var2 is equal or more -1
If Var2 is equal or less 1
in case all are true, than the Event has seen you.
Textbox: I can see you Down there. Wait 180Frames

If Var1 = 4
If Var3 is equal or more -1
If Var3 is equal or less 1
If Var2 is equal or more -6
If Var2 is equal or less 0
in case all are true, than the Event has seen you.
Textbox: I can see you on the Left. Wait 180Frames

If Var1 = 6
If Var3 is equal or more -1
If Var3 is equal or less 1
If Var2 is equal or more 0
If Var2 is equal or less 6
in case all are true, than the Event has seen you.
Textbox: I can see you on the Right. Wait 180Frames

If Var1 = 8
If Var3 is equal or more -6
If Var3 is equal or less 0
If Var2 is equal or more -1
If Var2 is equal or less 1
in case all are true, than the Event has seen you.
Textbox: I can see you Up there. Wait 180Frames

Edit:
This is just one example, depending on the kind of vision shape, there are different calculations.
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Ooops ended up trying out making my own A2 tile page instead of testing doors everywhere. Went well so far I think.
I guess I'm done making a blue squirrel's life difficult for posting new threads on different forums.
That's just for today so don't get used to this, squirrel-ish friend! :p
Got new hard drive, now trying to install the softwares I lost to the dead drive, and more than half of them won't install because they're already installed on the dead drive, and uninstallers won't run because they can't find where their programs are installed. So I take it having a drive die on you screws you in more ways than just data loss. >:\
PC got fixed finally. Back online again. Turns out I have no business trying to self repair pcs because it was getting to like 176F / 80C. Shop installed a totally new cooling system and now it runs fine and is super quiet.
When you're making major progress, but have to stop to go to work.

Forum statistics

Threads
131,486
Messages
1,220,212
Members
173,225
Latest member
ZecaVn
Top