MV Left/right and up/down cancels out

Hi everyone!

I am using San Analog movement, but this is not a plugin support request.

When I press left and right together (or up and down), the player doesn't move. Generally with games like binding of Isaac etc, it will respond to the LAST key pressed in each dimension (ie up/down or left/right)

It means when you're running around it stops moving every so often when there's an overlap of keys, which is very common with this type of movement.

All pixel movement plugins have this problem. Does anyone know of a solution to this? San said this is hard coded into the engine so may not be doable at all.

Hoping there's a rough and ready solution, I have considered trying to mess with movement using events but there is no recognition of 'key is released' and this seems like a messy solution

My js is unfortunately not up to scratch to mess with the main code.
I don't know the solution to this but just out of curiosity... what's the use case in which this (LEFT and RIGHT cancelling each other out) poses a problem?
what's the use case in which this (LEFT and RIGHT cancelling each other out) poses a problem?
they mentioned binding of isaac, where its very relevant since its a bullet hell game.
if you need to dodge left while youre already walking right, you dont have to lift your finger off of right to go left. you just press left while youre already going right and youll immediately go left without the delay of switching.
they may be going for a similar kind of game
Try creating a new project without any additional Plugins and test it.
If it works, go back to your current project and disable Plugin by Plugin until you discover the cause of the discrepancy.
Try creating a new project without any additional Plugins and test it.
If it works, go back to your current project and disable Plugin by Plugin until you discover the cause of the discrepancy.
The problem here is that left and right cancelling each other out is vanilla behavior. I’m searching for any clues (I mean, op cannot be the first one to run into this problem…) but so far no luck.
Very lightly tested:
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Prioritise most recent opposed directional input.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/163834/
 * @help Free to use and/or modify for any project, no credit required.
 */
void (function() {
'use strict';

  /** Recent X/Y direction property identifiers. */
  const X = "_recentX";
  const Y = "_recentY";

  /** Local proxy target for `Input._currentState`. */
  let s = null;

  // Set up proxy to intercept directional inputs.
  const alias = Input.clear;
  Input.clear = function() {
    alias.apply(this, arguments);
    delete this[X];
    delete this[Y];
    this._currentState = new Proxy(s = this._currentState, {
      get: function(obj, prop) {
        switch (prop) {
          case "left":
          case "right":
            const x = Input[X];
            if (x && x !== prop && obj[x])
              return false;
            break;
          case "up":
          case "down":
            const y = Input[Y];
            if (y && y !== prop && obj[y])
              return false;
            break;
        }
        return obj[prop];
      },
      set: function(obj, prop, value) {
        switch (prop) {
          case "left":
          case "right":
            if (value)
              Input[X] = prop;
            else
              delete Input[X];
            break;
          case "up":
          case "down":
            if (value)
              Input[Y] = prop;
            else
              delete Input[Y];
            break;
        }
        obj[prop] = value;
        return true;
      }
    });
  };

})();
And since this will require a core script edit, i.e. a plugin~

I've moved this thread to Plugin Requests (from MV Support). Thank you.


[Edit: added lines to clear recent X/Y memory on input clear & init s to the existing object instead of a new one.]

Original thread: https://forums.rpgmakerweb.com/threads/left-right-and-up-down-cancels-out.163834/