- Joined
- Feb 28, 2019
- Messages
- 15
- Reaction score
- 1
- First Language
- English
- Primarily Uses
- RMMV
I would like to control the movement of an event purely through javascript. Using Yanfly's movement plugin (YEP 124) I have the script command this.moveToPoint(x, y) seems like what I want but I get odd results because I don't know how to pass control back to the game's scene manager.
For example, I tried to do something like the following code:
but instead of seeing the event move smoothly towards the destination it looks like it teleports most of the way there and walks the last few steps. I think this is because the RMMV scene manager needs to take control to update the event location but of course my loop has control.
I know I can achieve the desired effect using event pages, self switches, and custom move route but I would like to know how to do this in pure javascript. Do I need to setup some kind of asynchronous function or something else?
Thanks.
For example, I tried to do something like the following code:
Code:
for (;;) { // I want event to move until it reaches destination
if (myEvent.x === destX && myEvent.y === destY) {
break // exit loop since destination reached
}
myEvent.moveToPoint(destX, destY, true) // step toward destination
$gameMap._interpreter.wait(20) // let display catch-up
}
I know I can achieve the desired effect using event pages, self switches, and custom move route but I would like to know how to do this in pure javascript. Do I need to setup some kind of asynchronous function or something else?
Thanks.

