Disable Player Movement Without AutoRun or Activate Events During AutoRun?

nephlm

Villager
Member
Joined
May 20, 2019
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
Hello Everyone,

I have been trouble shooting an issue for a while and I am completely out of ideas.

During a part of my game I want to deactivate and activate movement keys (eg. LEFT and UP are active, Down and Right are inactive, so player can only move UP and LEFT). I tried using an autorun event to stop player movement. Inside that event It searches for the buttons the player is pressing and sets a move route for the player if they are pressing an active button.

The problem is that I also have player touch and event touch events that need to be triggered at this time. Unfortunately, these events can't be triggered during an autorun.

Does anyone know of a way to trigger player touch/event touch events during an autorun event? Or, as an alternative, does anyone know how to temporarily disable player movement key options?

Also, I already tried YanFly's Button Common Event plugin to set the disabled keys to blank common events. The only problem is that there appears to be a glitch where going into the start menu removes the native function of the buttons.

If anybody has any advice I greatly appreciate it.
 
Last edited:

Eliaquim

Hakuen Studio
Veteran
Joined
May 22, 2018
Messages
1,415
Reaction score
667
First Language
Portuguese - Br
Primarily Uses
RMMV
You can use your autorun event to also check if the player touches the events, checking if they are in the same position. But depending on how many events you have, it can be a lot of work.
I don't know for sure, but maybe you can change the input key mapper with script calls:

Input.keyMapper[keyboardCode] = '';

Then you can put it back to normal when you finish what you are doing:

Input.keyMapper[keyboardCode] = 'up'

Here you can take a look of all keys that hold up/down/left/right:

37: 'left', // left arrow
38: 'up', // up arrow
39: 'right', // right arrow
40: 'down', // down arrow
98: 'down', // numpad 2
100: 'left', // numpad 4
102: 'right', // numpad 6
104: 'up', // numpad 8

Input.keyMapper[37] = ''; //Disable left button

Input.keyMapper[37] = 'left'; //Enable left button again.


I never tried this, but be cautious because this will disable the input for all scenes, including the menu.

Another way is to block the player's movement with events. Then you put the events to follow the player position so he cannot go to the direction you want to restrict.

Or you can search for a plugin that does that. I think poryg has one.
 

Bex

Veteran
Veteran
Joined
Aug 2, 2013
Messages
1,447
Reaction score
390
First Language
German
Primarily Uses
RMMV
1. Delete your Autorun Event.
2. Create an Event, set Trigger to Parallel.
3. Eventcommands:
- Loop
- 1 Frame Wait
- Conditional Branch Down Button is being pressed?
If yes: Set Movement Route Player: Wait 4 Frames (DO NOT Mark Wait for Completion, No Repeat, skip doesnt matter)
no else case

- Conditional Branch Right Button is being pressed?
If yes: Set Movement Route Player: Wait 4 Frames (DO NOT Mark Wait for Completion, No Repeat, skip doesnt matter)
no else case
repeat above

This prevents the player from moving into that direction.

The extra Loop was needed in vxace to get the button checked every frame, that was needed so no bugs occur, not sure with mv, but it should not hurt to have the extra loop. Just experiment with it and let us know how it went.

Edit: Maybe you can use 2 instead of 4 Frames wait for the Player Moveroute.
 

nephlm

Villager
Member
Joined
May 20, 2019
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
Thanks you guys for the replies! I will be playing around with the options you suggested over the next few days and I'll let you know how it turns out.
 
Last edited:

nephlm

Villager
Member
Joined
May 20, 2019
Messages
7
Reaction score
1
First Language
English
Primarily Uses
RMMV
I've been trying out some of the suggestions so I thought that I'd give you all an update.

I actually have two events that I needed to disable buttons for. The first one is pretty basic and the other one is a little more complex.

I have gotten the easier event working using Bex's suggestion. It worked well using just a 2 frame wait.

These events are fairly isolated from the rest of my game so I also tried using the script calls to disable buttons. Unfortunately, I encountered a bug for which I could not find a work around. If the player was holding down a button when it was disabled with script calls then the character would repeat the movement until the movement was reenacted (eg. player holds left -> I disable left ->character moves left until left is reactivated and pressed down).

Next I am going to try getting my more complex event to work. This event actually involves not just disabling buttons but also regularly remapping buttons. I will try to adapt Dex's suggestion to this event and see if I can get it to work.

Thanks again.
 

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

Latest Threads

Latest Profile Posts

What does your project folder look like?
I was told that an iPhone can provide a personal internet hotspot...You learn something new everyday!
Will probably never use MZ. Buys it anyway
Been playing Star Ocean: The Last Hope, the remastered version on PS4. I like it. Seems others think it's garbage, but I like these cutesy, silly, and tropey characters. Having waaaay more fun with it than SO: Integrity and Faithlessness.

Forum statistics

Threads
100,458
Messages
976,161
Members
132,082
Latest member
nwr
Top