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,875
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,875
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,875
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 Posts

Latest Profile Posts

You know you've been working on RPGMaker for a while when you go to move your projects to a 16 GB USB drive and get told not enough space to do this operation.
The latest post on TheDazzlingsAreBack...
besides itch and occasionally here where are people doing game jams at y'all? (plz do not cross reference this with my previous status lol)
Go out all day!
★No work★
Just want to sleep when I get home Zzzzz
just went through 50 issues of Fables, only to left kind of disappointed by it, I guess I have to wait for season 2 of TWAU instead.

Forum statistics

Threads
110,442
Messages
1,053,323
Members
143,510
Latest member
MiltonvaderBR
Top