[Solved] How can a player turn towards an event on "Event Touch"?

Status
Not open for further replies.

Sepheyer

Veteran
Veteran
Joined
Jul 20, 2021
Messages
74
Reaction score
39
First Language
English
Primarily Uses
RMMZ
I have NPCs that go on their business but do a "greeting" whenever they touch the hero. I do not know how to make the hero turn towards the NPC that is greeting her.

I attached a screenshot to illustrate this: red dress is the hero, an NPC north (above) of her proceeds on his path south (down).

EventQuestion.png

NPC touches the hero while the hero is looking south (down). At that point a greeting event fires off. The inconvenience is that the hero is looking down, yet it would be so much better if she turned towards the NPC just before her part of the greeting.

Would anyone have suggestions on how to maker her turn towards an event that touches her?

Thank you.
 
Last edited:

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
1,471
Reaction score
1,059
First Language
Polish
Primarily Uses
RMMZ
If the event is always going from up, why not just set player face up? Unless event is using pathfinding, but I don't think so if you didn't mentioned this.
 

Sepheyer

Veteran
Veteran
Joined
Jul 20, 2021
Messages
74
Reaction score
39
First Language
English
Primarily Uses
RMMZ
@fizzly, thank you.

Indeed, the movement is every which way, imitating pedestrian traffic.

Some NPCs move in straight line, other NPCs have L-like looking paths:

EventQuestion2.png
 

fizzly

Veteran
Veteran
Joined
Mar 23, 2012
Messages
1,471
Reaction score
1,059
First Language
Polish
Primarily Uses
RMMZ
In that case, make a condition branches. If pedestrian is looking right, then turn player left. If pedestrian looking down, then turn player up. And do 4 conditions for every direction, before they start to talk.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,516
Reaction score
3,557
First Language
EN
Primarily Uses
RMMZ
And if you use it a lot then you could make it a common event (in the database), e.g.
◆If:This Event is facing Down ◆Set Movement Route:Player (Wait) : :◇Turn Up ◆ :Else ◆If:This Event is facing Left ◆Set Movement Route:Player (Wait) : :◇Turn Right ◆ :Else ◆If:This Event is facing Right ◆Set Movement Route:Player (Wait) : :◇Turn Left ◆ :Else ◆Set Movement Route:Player (Wait) : :◇Turn Down ◆ :End ◆ :End ◆ :End
Then just call that at the start of every NPC event that does this~
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
23,401
Reaction score
13,068
First Language
English
Primarily Uses
RMMZ
I hesitate to enter into an MZ discussion, but in Ace this could be done with a simple script call in the set move route of the NPC. Obviously this would need to be translated from Ruby to Javascript, (e.g. I believe $game_map becomes $gameMap, but beyond that I don't know) but once that is done, might it work?

In the greeting event command on the NPC, include a set move route with the subject 'Player', then use this within that move route:

Script: turn_toward_character($game_map.events[15])

Change the [15] to the id of the NPC.
 

Sepheyer

Veteran
Veteran
Joined
Jul 20, 2021
Messages
74
Reaction score
39
First Language
English
Primarily Uses
RMMZ
@caethyrill, thank you! I tested it and it works like a charm, here is an illustration:



caethyril's code inside a common event:

PFE01.png

Then every NPC calls it from their "greeting" event page:

PFE02.png
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,516
Reaction score
3,557
First Language
EN
Primarily Uses
RMMZ
@Sepheyer: great, happy RPG Making~ :kaojoy:

In the greeting event command on the NPC, include a set move route with the subject 'Player', then use this within that move route:

Script: turn_toward_character($game_map.events[15])
I think the RMMV/Z equivalent would be this, in a move route Script:
JavaScript:
this.turnTowardCharacter($gameMap.event(15));
Personally, I think I'd suggest this instead, in a standalone Script command:
JavaScript:
$gamePlayer.turnTowardCharacter(this.character(0));
I.e. "make the player turn towards This Event". I was avoiding script calls to show it can be done with no scripting knowledge, but this is a nice concise alternative!
 

Sepheyer

Veteran
Veteran
Joined
Jul 20, 2021
Messages
74
Reaction score
39
First Language
English
Primarily Uses
RMMZ
@caethyril, where would I find reference to "turnTowardCharacter"?

The console doesn't show it unless you typed "turn". So, can't learn about this function from console.

This isn't in the "rmmz_objects.js". So, not there either.

Not in the very helpful reference posted by @Archeia.

Could you let me know how I can go about learning about functions such as TTC, which appears to me to be undocumented so far.

Thank you.
 

caethyril

^_^
Global Mod
Joined
Feb 21, 2018
Messages
4,516
Reaction score
3,557
First Language
EN
Primarily Uses
RMMZ
@caethyril, where would I find reference to "turnTowardCharacter"?

The console doesn't show it unless you typed "turn". So, can't learn about this function from console.

This isn't in the "rmmz_objects.js". So, not there either.
Actually, it is defined in rmmz_objects.js: line 7803 (v1.3.2). :kaohi:

I learned about the various methods by spending a lot of time reading through the core scripts. Lots of Ctrl+F! If you want to learn in a similar way, consider starting with the event commands in rmmz_objects.js: each of them are labelled with a comment, e.g. // Show Picture.

There are various resources for learning about RMMV's core scripts, e.g.


RMMZ's core scripts use similar method names and flow control in many areas so those might help. Not sure if there's anything similar for RMMZ. You might find something helpful on one of these boards:
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
10,116
Reaction score
6,400
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Latest Threads

Latest Posts

Latest Profile Posts

Shoot.gif
Because The Fury from Metal Gear Solid 3 is one of my favorite bosses of all time, I felt the need to make a somewhat similar boss for my own game. taking cues from both the Fury and another awesome astronaut boss, Captain Vladimir from No More Heroes 2.
RE4make almost had me with their demo until I got to the dog stuck in a bear trap and realized that he was dead and could no longer be saved. Just not the kind of reimagining I'm interested in.
Here's some dudes that I'm drawing for Jimmy's Quest!
autredo.png
Autism Acceptance Month 2023!


Did this randomly in my free time, I guess today is a good day to show it.

Forum statistics

Threads
130,024
Messages
1,207,116
Members
171,289
Latest member
MJDNK
Top