How to Make an Event Detect Player Proximity

Fufi_Saintz

Regular
Regular
Joined
May 14, 2020
Messages
84
Reaction score
31
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
5,272
Reaction score
4,756
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
Regular
Joined
Sep 20, 2021
Messages
2,279
Reaction score
1,713
First Language
English
Primarily Uses
RMMV
You can try Krons AI base
 

Bex

Regular
Regular
Joined
Aug 2, 2013
Messages
1,996
Reaction score
794
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 Profile Posts

made an RTP edit to try to save on work, found out I was editing the wrong tilesheet of cliffs.
It's fine... I'm fine... I'm sure fixing this won't take too long
Proud of the work done.
Probably gonna toss out some cameos.
-Message sponsored by the β Gang.
"I WAN BOOZY EGGY-NOG!"
"I WAN BOOZY EGGY-NOG!"
"For the love of the cosmos TarTar, you shouldn't drink spiked eggnog."
"I WAN BOOZY EGGY-NOG"
Boozy-Eggy-Nog.png
I've always found Game Over screens to be a bit boring. Mostly because I see them too often.
Tried to mix it up for the jam.
GameOver.png

Forum statistics

Threads
136,904
Messages
1,271,288
Members
180,689
Latest member
pharaoh14
Top