I'm using a certain line of code to make enemies move to a specific point on the map. It works fine with just one, but problems arise once I add a second enemy. Once one enemy reaches its specific map point, the other stops. I don't know much about Javascript, so I can't be 100% certain as to why this is happening. However, my guess is that since both lines of code are basically the same, it's using the same variable in some place. (Might not make much sense, but again, my Javascript knowledge is limited.
Below is the line of code I'm using for one of the enemies. (The other is the exact same except for the cords). I'm hoping someone could help me understand this code and how to make it work.
Below is the line of code I'm using for one of the enemies. (The other is the exact same except for the cords). I'm hoping someone could help me understand this code and how to make it work.
JavaScript:
var d = this.findDirectionTo(9, 9); if (!d || !this.canPass(this.x, this.y, d)) { this.forceMoveRoute({ list: [{ code: 0 }] }); this.setMovementSuccess(true); this._moveRouteIndex--; } else this.moveStraight(d);