[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
59
Reaction score
29
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,052
Reaction score
684
First Language
Polish
Primarily Uses
RMMV
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
59
Reaction score
29
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,052
Reaction score
684
First Language
Polish
Primarily Uses
RMMV
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
2,958
Reaction score
2,292
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
22,512
Reaction score
12,003
First Language
English
Primarily Uses
RMVXA
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
59
Reaction score
29
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
2,958
Reaction score
2,292
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
59
Reaction score
29
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
2,958
Reaction score
2,292
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
9,112
Reaction score
5,963
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

1638170340913.png
Crossover Inn is getting very crowded, and I love it
Climbing to the top #mapping
1638160732198.png
I've started the first steps of the final few maps that I need to make for B:ms. I haven't been able to say that in a really, really long time. It'd probably be a good idea to blog about this or something.
Question for the Mods: What am I supposed to do when I can't make a synopsis 350 words long? (for project recruitment thread) @Shaz @mlogan
The game is meant to be more on the simple side in order to be achievable so I'm a bit stuck...

Forum statistics

Threads
117,043
Messages
1,104,082
Members
152,988
Latest member
mur2fer
Top