Block player movement

Status
Not open for further replies.

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
419
Reaction score
12
First Language
French
Primarily Uses
I look for a way to block player movement.
I just want to have control when he can move or not in mycinematic.
For be able at start of cinematic to disable his movement and enable them back at the end.

Please not, these event cannot be run in autorun for various reason.
I really need a way to block and unblock player in a line of code.


Thanks.
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Call these by event script. EDIT #2: forgot to add number pad keys too, not just arrow keys
JavaScript:
// disable move by 4 directions
var pe = {37:false,38:false,39:false,40:false,98:false,100:false,102:false,104:false};
for(i in pe) Input.keyMapper[i] = pe[i];
and re-enable with this
JavaScript:
// enable move by 4 directions
var pe = {37:"left",38:"up",39:"right",40:"down",98:'down',100:'left',102:'right',104:'up'};
for(i in pe) Input.keyMapper[i] = pe[i];
interestingly enough, you can get creative with this script to reverse the direction for some kind of funky magic spell, and use the same enable function to go back
JavaScript:
// reverse by 4 directions (this is cruelty)
var pe = {37:"right",38:"down",39:"left",40:"up",98: 'up',100:'right',102:'left',104:'down'};
for(i in pe) Input.keyMapper[i] = pe[i];
 
Last edited:

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
419
Reaction score
12
First Language
French
Primarily Uses
Call these by event script. EDIT #2: forgot to add number pad keys too, not just arrow keys
JavaScript:
// disable move by 4 directions
var pe = {37:false,38:false,39:false,40:false,98:false,100:false,102:false,104:false};
for(i in pe) Input.keyMapper[i] = pe[i];
and re-enable with this
JavaScript:
// enable move by 4 directions
var pe = {37:"left",38:"up",39:"right",40:"down",98:'down',100:'left',102:'right',104:'up'};
for(i in pe) Input.keyMapper[i] = pe[i];
interestingly enough, you can get creative with this script to reverse the direction for some kind of funky magic spell, and use the same enable function to go back
JavaScript:
// reverse by 4 directions (this is cruelty)
var pe = {37:"right",38:"down",39:"left",40:"up",98: 'up',100:'right',102:'left',104:'down'};
for(i in pe) Input.keyMapper[i] = pe[i];
If I understand, you actually blocking keyboard button. But what if player use mouse or hud with arrow?
 

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Doh! I didn't think of that.

Try these to disable click move.
// disable move by click
if(Game_Character.prototype.findDirectionToCached === undefined)
Game_Character.prototype.findDirectionToCached = Game_Character.prototype.findDirectionTo;
Game_Character.prototype.findDirectionTo = function(){
return false;
}

and to re-enable
// enable move by click
Game_Character.prototype.findDirectionTo = Game_Character.prototype.findDirectionToCached;


EDIT: RPG Maker MV has HID support too? Hold on a second. I'm dumb.
 
Last edited:

mogwai

1984
Veteran
Joined
Jun 10, 2014
Messages
875
Reaction score
591
First Language
English
Primarily Uses
RMMV
Ignore those other two ideas. This will cancel all three possible inputs' movement at once.
PHP:
// disable move by all input
if($gamePlayer.moveByInputCached === undefined)
    $gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
$gamePlayer.moveByInput = function(){
    return false;
}
and to enable
PHP:
// enable move by all input
$gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
 
Last edited:

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
419
Reaction score
12
First Language
French
Primarily Uses
Ignore those other two ideas. This will cancel all three possible inputs' movement at once.
PHP:
// disable move by all input
if($gamePlayer.moveByInputCached === undefined)
    $gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
$gamePlayer.moveByInput = function(){
    return false;
}
and to enable
PHP:
// enable move by all input
$gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
Thanks, that perfect. Any way to mark you for best answer? I did't find the button with the new forum updat.
By the way, if I disable in some part of the game the mouse move, if I put a cute scene with these setting, that will reanable it?
 

doranikofu

Veteran
Veteran
Joined
Oct 4, 2015
Messages
113
Reaction score
31
First Language
Chinese
Primarily Uses
have you looked at YEP_stopmapmovement plugin?
 

XGuarden

Veteran
Veteran
Joined
May 10, 2016
Messages
419
Reaction score
12
First Language
French
Primarily Uses
have you looked at YEP_stopmapmovement plugin?
In the past yes, but I did't remember why I did't use it. I think it's something with compatibility issue with other plugging.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
30,737
Reaction score
7,378
First Language
German
Primarily Uses
RMMV
[closed]IgnoreMe[/closed]
 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Ok i got the model New and I will develop a little more, I think my SV is not beautiful yet.
"I, Giorno Giovanna, have a dream". In all seriousness, spatial BGM feature is now complete for my audio plugin.
Stream will be live shortly with some game development followed by the return of the Interactive Text Adventure after a short hiatus! Feel free to drop by!
Lately, I've taken to smashing random nouns/verbs together as insults. It's sort of amusing how many people don't really know how to respond to that. You bottle shaker!
Would be nice to pick color code that is not exclusively for message event

Forum statistics

Threads
103,243
Messages
998,316
Members
134,733
Latest member
Shadowgrahp
Top