RMMV Lock player movement while holding down mouse button? (not autorun)

Status
Not open for further replies.

Oir

Veteran
Veteran
Joined
Dec 19, 2020
Messages
104
Reaction score
46
First Language
English
Primarily Uses
RMMV
Hello all!

I would like for my player's movement to lock specifically when the player is holding down the mouse button.

However, the player should still be allowed to use skills and otherwise input commands while this is happening. It's just the movement that I'd like to be locked (hence why I don't really see autorun being a good solution here).

Any ideas would be greatly appreciated! Thank you for your time!
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV
What do you mean by "lock movement"? That the player cannot move? That movement is automatic but only in one direction? That the player continues to move and follow the mouse as long as the button is held?

How is the player going to use skills or input commands if they are already holding down the mouse button? Using skills or inputting commands requires them to click the mouse button, doesn't it? How can they click a button that is already being held down?
 

Oir

Veteran
Veteran
Joined
Dec 19, 2020
Messages
104
Reaction score
46
First Language
English
Primarily Uses
RMMV
What do you mean by "lock movement"? That the player cannot move? That movement is automatic but only in one direction? That the player continues to move and follow the mouse as long as the button is held?

How is the player going to use skills or input commands if they are already holding down the mouse button? Using skills or inputting commands requires them to click the mouse button, doesn't it? How can they click a button that is already being held down?

Apologies for being too vague. I mean that the player should be stuck in place, unable to move in any direction. In my game, the player can do things such as teleporting or attacking with the z and x keys since it's an ABS game.

So I'd still like him to be able to use those kinds of skills while his movement is locked (as in he could still, say, heal himself or use another attack while being unable to move).

I guess you could also approach it as the arrow keys/WASD get disabled while the mouse button is held down? (But I don't know how to do that either).

Thank you for the response and sorry again for not being clear
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV

I have moved this to Plugin Requests



Try saving the following into your plugins folder - call the file DisableMove.js or something like that - name doesn't really matter. I have not tested this, so it might not work properly.

Code:
var _noMove_GamePlayer_canMove = Game_Player.prototype.canMove;
Game_Player.prototype.canMove = function() {
  return _noMove_GamePlayer_canMove.call(this) && !TouchInput.isPressed();
}
 

Oir

Veteran
Veteran
Joined
Dec 19, 2020
Messages
104
Reaction score
46
First Language
English
Primarily Uses
RMMV
[mod]I have moved this to Plugin Requests[/mod]

Try saving the following into your plugins folder - call the file DisableMove.js or something like that - name doesn't really matter. I have not tested this, so it might not work properly.

Code:
var _noMove_GamePlayer_canMove = Game_Player.prototype.canMove;
Game_Player.prototype.canMove = function() {
  return _noMove_GamePlayer_canMove.call(this) && !TouchInput.isPressed();
}

It works perfectly! I don't know what to say; I didn't expect you to just up and write a script for me!
I really appreciate you taking the time to help me out like this.
 

Shaz

Global Moderators
Global Mod
Joined
Mar 2, 2012
Messages
41,879
Reaction score
14,525
First Language
English
Primarily Uses
RMMV
It was easy/quick :) Glad it works.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
  • Like
Reactions: Oir
Status
Not open for further replies.

Latest Threads

Latest Profile Posts


Swag collecting in the new randomly generated area. Now the mini map also shows the randomly generated features... And even illustrates the whole "bubble" system" that I made to manage memory... Though that part's inadvertent. We'll just call that "the fog of war"... Yes, that's what we'll do. Nobody will be the wiser! :kaopride:
not me being not lazy for 5 seconds and drawing another char portrait (her name is hazel)
its_hazel.png
Been a while since the last time I made a song remix. Had a blast making this
One thing those jp developer still get wrong about boob physic is that... men's muscly hard pecs can jiggle too.
Definitely glad I haven't released a few of my plugins that are technically done. As I learn more, I find ways to make my code more efficient, and in one case so far, discovered an existing function that did EXACTLY what I created my own function to do.

Forum statistics

Threads
110,454
Messages
1,053,435
Members
143,541
Latest member
Neikoku
Top