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

rhapsodymipo

Villager
Member
Joined
Jan 30, 2015
Messages
20
Reaction score
6
First Language
portuguese
Primarily Uses
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
 

Mike-Turtle

Veteran
Veteran
Joined
Apr 17, 2021
Messages
80
Reaction score
186
First Language
English
Primarily Uses
RMMV
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.
 
Last edited:

rhapsodymipo

Villager
Member
Joined
Jan 30, 2015
Messages
20
Reaction score
6
First Language
portuguese
Primarily Uses
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
 
Last edited:

Mike-Turtle

Veteran
Veteran
Joined
Apr 17, 2021
Messages
80
Reaction score
186
First Language
English
Primarily Uses
RMMV
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.
 

rhapsodymipo

Villager
Member
Joined
Jan 30, 2015
Messages
20
Reaction score
6
First Language
portuguese
Primarily Uses
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
 

Latest Threads

Latest Posts

Latest Profile Posts

ScreenShot_6_28_2022_3_2_40.png

There's 7 main areas in the game that are all connected. This train get's you from an underground lab to the center of someone's subconscious. inside the train you can talk to some of the passengers. but going to the top of it, there's battles.
Speedrunning all character portraits just so they all have the same quality. Not sure if this was a good idea, but now I'm almost done.
We now have a gameplay video!
DrBuni wrote on Akiritas's profile.
That is a cute Link picture, reminds me of the Samurai Jack artstyle.
I had an idea on how to get my encounters to leash after chasing the player for a little bit. After going down the Javascript rabbit hole, I realized I could do it in a regular movement route. Derp!

Forum statistics

Threads
123,145
Messages
1,154,371
Members
161,488
Latest member
rybaspi
Top