Walk/Running using only the mouse

Hello!

I'm trying to make a game which is designed to be played with the mouse, however, I'm having issues making the character run and walk at the same time using only the mouse.

I thought of holding the click for half second would trigger the run animation, while just clicking would be the walking animation. However, my knowledge about javascript is very limited.

I wondering if anyone knows how to do this?

Thanks and sorry if my english is bad!
Are you already using a plugin for this "run" part? If yes, which plugin?

By default, MV doesn't have any such thing as a run animation.

There is dashing, but that's just moving faster. You could probably get a not-too-complicated plugin whipped up to make you dash if you're holding down the mouse button, or maybe walk with left-click and dash with right-click.

If you need it to interact with another plugin to change the character sprites, that could be more complicated.
Are you already using a plugin for this "run" part? If yes, which plugin?

By default, MV doesn't have any such thing as a run animation.

There is dashing, but that's just moving faster. You could probably get a not-too-complicated plugin whipped up to make you dash if you're holding down the mouse button, or maybe walk with left-click and dash with right-click.

If you need it to interact with another plugin to change the character sprites, that could be more complicated.
I'm not using any run plugin. The only plugin related to movement I'm using is a Diagonal Movement one but I don't think they will interefere with each other. I was thinking just changing the sprite after the run mechanic triggers. I just have no idea how to make a plugin like that and not sure if one exists already.
You can try this:
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Hold touch input to run/dash, press & release to walk.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/157975/
 * @help Free to use and/or modify for any project, no credit required.
 */
// Should run during touch movement only while touch input is held.
void (function(alias) {
  Game_Player.prototype.isDashing = function() {
    if ($gameTemp.isDestinationValid())  // if touch move target is active
      return TouchInput.isPressed();
    return alias.apply(this, arguments);  // otherwise default
  };
})(Game_Player.prototype.isDashing);

// Only change move destination on new touch.
void (function(alias) {
  Scene_Map.prototype.processMapTouch = function() {
    alias.apply(this, arguments);
    this._touchCount = 0;
  };
})(Scene_Map.prototype.processMapTouch);
You can try this:
Spoiler: plugin code
JavaScript:
/*:
 * @target MV MZ
 * @plugindesc Hold touch input to run/dash, press & release to walk.
 * @author Caethyril
 * @url https://forums.rpgmakerweb.com/threads/157975/
 * @help Free to use and/or modify for any project, no credit required.
 */
// Should run during touch movement only while touch input is held.
void (function(alias) {
  Game_Player.prototype.isDashing = function() {
    if ($gameTemp.isDestinationValid())  // if touch move target is active
      return TouchInput.isPressed();
    return alias.apply(this, arguments);  // otherwise default
  };
})(Game_Player.prototype.isDashing);

// Only change move destination on new touch.
void (function(alias) {
  Scene_Map.prototype.processMapTouch = function() {
    alias.apply(this, arguments);
    this._touchCount = 0;
  };
})(Scene_Map.prototype.processMapTouch);

Yeah! Thanks a lot for this! I really appreciate it. I'll need to tweak it a bit so it works exactly the way I want, I don't want to bother you too much so I'll try to figure it out first with some friends help.

Thanks again!
You're welcome, good luck! 👋

Original thread: https://forums.rpgmakerweb.com/threads/walk-running-using-only-the-mouse.157975/