setting NPC guard

Hello all. First post here.

I have a question about setting an NPC. What i want to do is make him patrol next to the castle gate, and when my character walks up and enters area of about 3 blocks away from the guard, he should run to the character, say something like a warning to back off and continue his regular patrol route, whyle my character would back off 1 or 2 steps back. And that process will have to repeat whenever character walks up in that region of 3 blocks.

I experimented with common events and animations but couldn't get it to work, so some help would be nice 🙂

Thanks in advance.
A possible solution is do it with helps from MOG-event sensor (or other event sensor) scripts. With that script you will make 2 pages, first page for routine move (patrol), and the second page is for sensor response (run to character).
Thanks, i will try that!

Original thread: https://forums.rpgmakerweb.com/threads/setting-npc-guard.35764/