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
44
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,149
Reaction score
14,206
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
44
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,149
Reaction score
14,206
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
44
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();
}

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,149
Reaction score
14,206
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 Posts

Latest Profile Posts

Does anyone know of NPC sprites for RMMZ? I know of Flirion's RMMV recolours, but RMMZ's sprites are slimmer and more detailed, so I'm a bit on the edge to use Flirion's im RMMZ...
I can't believe that after all those years, KH Union X Dark Road is closing the services.

Due to a situation in which I thought plugin adaptations had stopped for the QPlugins, I "ghetto" converted these 7 over yesterday. They appear to work perfectly as long as you use old style plugin commands. I am uncertain if I will have a lot of free time in the future to work on this, but if you'd like them, here they are.
Was there a thread that you could share a screenshot of your game? I feel like I found it once but can't locate it again.

I was being lazy and just copied a map to test a new parallax, but I forgot to delete all the events. This was the result. :o

Forum statistics

Threads
108,818
Messages
1,039,788
Members
141,276
Latest member
acoolusername
Top