MV Restrict a character from moving or facing up/down unless through scriptcall with Qmovement

Hello. So, i'm working on a sidescrolling project that relies on Quxios plugins for movement, and want the character to move sideways, unless specified. is it possible?
Additionally, is it possible to set the Qpathfind to move the character only on x coordinate? For example, in the image, when i click outside of the moving area, character is static, cause pathfind can't calculate the route. i'd like it to move sideways until the x position of the mouse click.

path.png

Yes. I'm only using 2dir sprites on my current project. Do you:
  • use Qabs?
  • need it for the player?
  • need it for other characters?
  • want them to only move on the X axis, or want them to only face left and right but still be able to move on the y axis?
As for your second post: no, not without huge rewrites.
Yes. I'm only using 2dir sprites on my current project. Do you:
  • use Qabs?
  • need it for the player?
  • need it for other characters?
  • want them to only move on the X axis, or want them to only face left and right but still be able to move on the y axis?
As for your second post: no, not without huge rewrites.
Thanks for your reply.
  • For now i was thinking of making a simple adventure style game, no abs involved.
  • Only the player for now, other characters only if it's not too much work.
  • Only moving the x axis would be preferable
Code:
Game_Player.prototype.moveByInput = function() {
    if (!this.startedMoving() && this.canMove()) {
      if (this.triggerAction()) return;
      var direction = QMovement.diagonal ? Input.dir8 : Input.dir4;
      if (direction > 0) {
        this.clearMouseMove();
      } else if ($gameTemp.isDestinationValid()) {
        if (!QMovement.moveOnClick) {
          $gameTemp.clearDestination();
          return;
        }
        this.requestMouseMove();
        if (this._requestMouseMove) {
          var x = $gameTemp.destinationPX();
          var y = $gameTemp.destinationPY();
          return this.moveByMouse(x, y);
        }
      }
      if (Imported.QInput && Input.preferGamepad() && $gameMap.offGrid()) {
        this.moveWithAnalog();
      } else {
        if ([4, 6].contains(direction)) {
          this.moveInputHorizontal(direction);
        } else if ([2, 8].contains(direction) && (!$gameSwitches.value(1))) {
          this.moveInputVertical(direction);
        } else if ([1, 3, 7, 9].contains(direction) && QMovement.diagonal) {
          this.moveInputDiagonal(direction);
        }
      }
    }
  };

Replace the moveByInput function in qMovement with this one. Change the value of $gameSwitches.value(1) to whatever number you like, and then when that switch is activated you won't be able to move on the Y axis.
Code:
Game_Player.prototype.moveByInput = function() {
    if (!this.startedMoving() && this.canMove()) {
      if (this.triggerAction()) return;
      var direction = QMovement.diagonal ? Input.dir8 : Input.dir4;
      if (direction > 0) {
        this.clearMouseMove();
      } else if ($gameTemp.isDestinationValid()) {
        if (!QMovement.moveOnClick) {
          $gameTemp.clearDestination();
          return;
        }
        this.requestMouseMove();
        if (this._requestMouseMove) {
          var x = $gameTemp.destinationPX();
          var y = $gameTemp.destinationPY();
          return this.moveByMouse(x, y);
        }
      }
      if (Imported.QInput && Input.preferGamepad() && $gameMap.offGrid()) {
        this.moveWithAnalog();
      } else {
        if ([4, 6].contains(direction)) {
          this.moveInputHorizontal(direction);
        } else if ([2, 8].contains(direction) && (!$gameSwitches.value(1))) {
          this.moveInputVertical(direction);
        } else if ([1, 3, 7, 9].contains(direction) && QMovement.diagonal) {
          this.moveInputDiagonal(direction);
        }
      }
    }
  };

Replace the moveByInput function in qMovement with this one. Change the value of $gameSwitches.value(1) to whatever number you like, and then when that switch is activated you won't be able to move on the Y axis.
It worked wonderfully. Thank you so much for the help and for your time

Original thread: https://forums.rpgmakerweb.com/threads/restrict-a-character-from-moving-or-facing-up-down-unless-through-scriptcall-with-qmovement.147929/