This is a simple question. How do you 'freeze' the player's control without an auto-run event? I think it's a bit risky to use sometimes but it's still useful to use if I don't want the player to have control. However, this is not optimal for certain situations (I mean it's good for cut-scenes but not for direct game-play), so is there a way to turn the control of the player on and off whenever I want? If not, what plugin would work well for this? Thanks!
How to Freeze the Player Without Auto-run
RPG Maker MV SupportYanfly has a plugin here however it comes in a bundle you have to pay for:
www.yanfly.moe
Not really worth it if you need only this one plugin. But go ahead and get it if the other plugins in there catch your eye. Yanfly plugins are great!
However, you can just use this snippet:
source: https://forums.rpgmakerweb.com/index.php?threads/block-player-movement.74387/
// disable move by all input
if($gamePlayer.moveByInputCached === undefined)
$gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
$gamePlayer.moveByInput = function(){
return false;
}
// enable move by all input
$gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
Stop Map Movement (YEP) - Yanfly.moe Wiki
However, you can just use this snippet:
source: https://forums.rpgmakerweb.com/index.php?threads/block-player-movement.74387/
// disable move by all input
if($gamePlayer.moveByInputCached === undefined)
$gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
$gamePlayer.moveByInput = function(){
return false;
}
// enable move by all input
$gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
Make an Event with Trigger Parallel and here are the Eventcommands:
Code:
◆If:Button [Down] is pressed down
◆Set Movement Route:Player (Skip)
: :◇Wait:2 frames
◆
:End
◆If:Button [Left] is pressed down
◆Set Movement Route:Player (Skip)
: :◇Wait:2 frames
◆
:End
◆If:Button [Right] is pressed down
◆Set Movement Route:Player (Skip)
: :◇Wait:2 frames
◆
:End
◆If:Button [Up] is pressed down
◆Set Movement Route:Player (Skip)
: :◇Wait:2 frames
◆
:End
I think it's cool you could potentially just use an event to stop the player's movement, but I don't know how reliable that'll be (though it could work). Perhaps I'll try the code first, even if it's a bit risky. Or I may not even need to, because I got Yanfly's Stop Movement plugin. I got it before it was locked behind a price tag. Can you use this plugin to directly control only the player? I didn't know that. I'll look into that and of course read the instructions (this is what I get for not reading the plugin's instructions to begin with). Now I have three options I could look into.
By the way, I noticed that the thread Hyouryuu-Na referred to had a bit of code that reversed the player's controls (up is down, left is right, and so on). Here's a picture of mogwai's code:
But the writer of the thread pointed out some sort of flaw with this structure. You can read more about it here, it's a short thread: https://forums.rpgmakerweb.com/index.php?threads/block-player-movement.74387/
Perhaps I could go to the JavaScript forum and see how to perfect this script so I could reverse the player's controls! Maybe an enemy could do this temporarily. But this isn't technically a forum for scripting. I just wanted to point this out to give people something to think about while I try my three options. I think reversing the player's controls is a cool idea. I might start a thread in the JavaScript forum to figure this out.
Unless it's 'not against the rules' to solve this coding problem right here. Anyway, back to my initial dilemma. I don't want to get too off track. I'll try and use the options available to me at the moment and will let you all know if I solved the issue.
Thanks for the help so far!
---- ----
Update: I tried all 3 options. The code and Yanfly's plugin had the same result. When I was transitioned to another map, I was locked in only one direction. I could move, but I looked silly when I walked backward or forward all the time. Then I tried using Bex's event method and it would've worked but then this error happened:
I guess it's because there was event commands after the wait frames and it didn't have time to process it or something.
Then I tried to re-enable the movement of the player on the map they transitioned to rather than the event on the other map. These are the commands I used:
This actually worked! It no longer locked the player in one direction when I initialized the commands. So that's that. I'll keep this up in case another issue happens, but other than that, thanks for helping me everyone!
By the way, I noticed that the thread Hyouryuu-Na referred to had a bit of code that reversed the player's controls (up is down, left is right, and so on). Here's a picture of mogwai's code:
But the writer of the thread pointed out some sort of flaw with this structure. You can read more about it here, it's a short thread: https://forums.rpgmakerweb.com/index.php?threads/block-player-movement.74387/
Perhaps I could go to the JavaScript forum and see how to perfect this script so I could reverse the player's controls! Maybe an enemy could do this temporarily. But this isn't technically a forum for scripting. I just wanted to point this out to give people something to think about while I try my three options. I think reversing the player's controls is a cool idea. I might start a thread in the JavaScript forum to figure this out.
Unless it's 'not against the rules' to solve this coding problem right here. Anyway, back to my initial dilemma. I don't want to get too off track. I'll try and use the options available to me at the moment and will let you all know if I solved the issue.
Thanks for the help so far!
---- ----
Update: I tried all 3 options. The code and Yanfly's plugin had the same result. When I was transitioned to another map, I was locked in only one direction. I could move, but I looked silly when I walked backward or forward all the time. Then I tried using Bex's event method and it would've worked but then this error happened:
I guess it's because there was event commands after the wait frames and it didn't have time to process it or something.
Then I tried to re-enable the movement of the player on the map they transitioned to rather than the event on the other map. These are the commands I used:
This actually worked! It no longer locked the player in one direction when I initialized the commands. So that's that. I'll keep this up in case another issue happens, but other than that, thanks for helping me everyone!
Original thread: https://forums.rpgmakerweb.com/threads/how-to-freeze-the-player-without-auto-run.124017/