I have lots of characters on my map, and I want them to look at the player when the player moves. There's a "turn toward player" option in Set Movement Route, this is what I want every event on the map to do.
Ideally I would want to have a parallel process event doing the following:
1. Get all events in the map
2. Set all events to player's direction
3. Wait for a short period of time
I wouldn't mind doing it with a custom script, but I'm not sure how to get an event array from the current map, and how to set each event's direction by calling the "turn toward player" method which I know exists. (My biggest frustration with MV is that I just can't find any documentation for any of this stuff).
Setting All Events On Map To Player's Direction
● ARCHIVED · READ-ONLY
-
-
Something like this? Create a separate parallel event and put in the script box.
Code:for(var i = 0; i < $gameMap.events().length; i++){ $gameMap.events()[i].turnTowardPlayer() } this.wait(num) //replace num with the number of frames you want the parallel event to wait for.
This is assuming that all of your events on the map are characters and not objects. If it is something like decorations, chests, or switches; then those may be affected to unfortunately (depending on how their spritesheets were laid out) unless direction fix is on for them.
Alternatively, you can just manually set each event's autonomous movement route from fixed to custom. Set the route to "Turn Toward Player" and "Wait...". It's a more monotenous way of doing it, but it'll ensure which events you want it to be affected and which ones you don't. As opposed to the script code above which will affect every single event. -
Yeah, I know it will affect all events, and already set them up accordingly.
Thanks for the snippet. Is there a place to see all possible methods of an object (all options for $gameMap.______)? I just can't seem to find in-depth documentation anywhere and end up guessing the methods half the time.
For instance, turnTowardPlayer() works, but instead of turnLeft you need to use setDirection [in this case setDirection(4)].
The code works OK, but I did eventually find it more natural-looking to set up custom movement route for each character with different 'wait' values. So it looks like they're all turning at their own time instead of all together (which looks rather unconvincing). Thanks for the reply! -
If you open up the dev console, typing in $gameMap followed by a "." usually has a set of autofills most properties you can select/change on that.
Otherwise, go to your js folder and open up rpg_objects.
There will be whole bunch of functions you can look at.
The one you are looking for is under "Game_Map" which is what is being called for when entering $gameMap.
I believe you may also want to look for "Game_Event" and "Game_Character" as those are events stuff that fall under $gameMap.event(eventId).
I think if you want the see all the possible options you have for events through the dev console's autofill. I believe you can just do $gameMap._events[num] followed by a "." at the end. If it autofills with a "_" at the beginning, those are things that you can make direct changes to while the ones that don't are functions that can be called upon.
As to indepth documentation of what each functions does, I don't know of any. I just end up trying to decipher what each code does and testing them out.