How to swap actors in the overworld w/ the press of a button (MV)? (solved :D)

Hello! I'm relatively new to RPGMaker and am currently learning the basics (I'm up to the point where I can transfer characters between maps atm and that's as far as my "advanced skills" with this engine go lol). I know a lot about what I want to do with my game, but not how to accomplish it.

One of the things I want to do is the swapping of actors while in the overworld (or, on the map instead of while in combat, though I do want to accomplish that as well and Yanfly's Actor Transformation looks promising).

Regardless, I want to know how to set up the swapping of actors at the press of a button. To give an example of what I mean: say that I want a player to be able to crouch at any time at any point in the map. To do this, I might have them press "C". This switches the actor from that of the standing character to that of the crouching character while on a map that allows crouching in any place any time.

I want to know how to accomplish this feature but I have no clue where to start. Old forums I've read through have pointed me towards the idea of "common events", "conditional branches" and "loops" which I'm afraid I have little clue on how to set up. How would I go about swapping actors in the overworld for one another and how can I do so so that the "transformation" happens at the press of a (specified) button? Also, since I plan to include battles, how do I force a detransformation when the player enters a battle if they've changed into this form?
I can try to guide you. So, there may be easier (or more efficient) ways to do this, but this is how I'd achieve it without plugins.

First (image 1), you'll set a common event (click the gear (1) and then go to common events (2)) with this configuration: Parallel and the switch you want to activate it. It can be any number of common event and any switch you prefer (3).

The switch will activate the parallel process, will make it start. The parallel process works in the background, it runs automatically without interfering in other processes.

Then, on the body of the event (image 2) you will create a new conditional branch command. Go to the forth page of the conditional branch and select script. Copy this: Input.isTriggered('xxx')
There is no way (at least I know of) to select a custom button on the button option, so it needs to be the script call. The xxx we will change later.
You can see I've set another switch in my example with another conditional branch to see if the flashlight is on or off. This way you can customize different behaviors for the button. If is off the flashlight will turn on and the switch will go on too, if is on they both will go off. You'll need to set similarly to this for it to work the way intended. Inside this branch you put the "change actor image" to the image you want (page 3 of the event command thing). You can deactivate the switch in step 3 to maps you don't want this to work. Or if you want to always check this, you can put a branch for certain maps and/or conditions. You can get creative here.

Now, the third step. Take care on this one, as you will deal with some core files (there are plugins for keybinding, but I'm not covering them). Make a backup, etc.
Go to your js folder inside your project folder and open rpg_core.js to edit it. On the line 3002 (or search for Input.keyMapper = {) you will see all the key bindings of the project. (Image 3) Add a line inside the { } (copy one if you feel over cautious).

Go to this website https://keycode.info/ and press the key you want to make. Let's say it's C. C is 67.
On the new line, change the number to 67, inside the '' you'll put the name of the key and the green stuff behind // is a comment. I suggest you put C + a name you can find easily after in a ctrl+F. (Right below is the gamepad config as well, if you want to enable it for controllers). Save.

Now, take the name you've put inside the '' and go back to your event. Remember the xxx? Change it to the name you gave. And that may be it. Maybe I forgot something, but just ask if you need. 🙂

Ah, now for the battles thing. Your battles aren't common battles? I mean, some kind of "in map" thing? Or do you mean after the battle they "reset"? You could just change the image again and put the switch off. In my case I have two flashlights, one common event in parallel for the F button and another for an actual item (not parallel) if one changes the other change it too.
On the Maps where you can crouch, create a Event and set its trigger to Parallel.
Here is the Eventcode copy pasted as Text, maybe it helps.
Code:
◆If:Button [Pageup] is pressed down
  ◆If:Switch0815 is OFF
    ◆Control Switches:#0004 Switch0815 = ON
    ◆Change Actor Images:Harold, Actor1(0), Actor1(1), Actor1_1
    ◆
  :End
  ◆
:Else
  ◆If:Switch0815 is ON
    ◆Control Switches:#0004 Switch0815 = OFF
    ◆Change Actor Images:Harold, Actor1(0), Actor1(0), Actor1_1
    ◆
  :End
  ◆
:End
If = Conditional Branch Eventcommand
Pageup Button is the Q Button on the Keyboard

Edit: Aslong the Q Button is pressed the Actor Image stays changed, when the Button is released,
the Actor Image changes back.
Edit: The Map Image is not the one used in Battle. So nothing to worry about i guess.
sorry for the late reply,, got busy w/ irl stuff. Thanks so much for the replies though, both answers seem to be getting towards what I want it's just a matter of me figuring out how to mimic them now because I tried copying both of your guy's steps as you listed them and got confused at certain areas (mostly regarding the aspect of variables and switches because I'm a bit confused by them as listed here atm)

@spec3 I can get as far as putting in the "If Input is triggered" line on the conditional branch but I got confused at the "if flashlight is on" command (which I assume is what number 4 correlates to on the images you attached?). I'm unsure exactly what that means in terms of what I need to select (especially since I assume there's something on the control variables page I specifically need to pick) so I don't know the steps I need to take in order to mimic that efficiently.

Also, just because I was a little confused about this, I noticed you had the crouching guy example under common event 20 but in the area where you input the trigger as a parallel switch in question had #14 for switch. I'm guessing switches and events are two different things, but I'm curious whether or not the switches are listed anywhere (especially to keep track of them, since I assume using the same switch for different control events could get messy).

I've attached an image with as far as I've gotten for reference

@Bex I got as far as "if switch 0815" is off but there are some things confusing me (mostly regarding the naming of switches because I got lost there lol). I think switch 004 is the one I'm setting up as being parallel, correct? And the switch 0815 is the hypothetical thing that checks whether or not I have the actor change already on or off, right? At least, that's what I think is going on but I haven't been able to replicate the "Control Switches:#0004 Switch0815 = ON" code (I've got as far as "Control Switch #0003 = off" but after that idk what I'm doing). I'm guessing there's some specific way to get that kind of code showcased (the control switches menu doesn't seem to be it tho??) and from what I can guess I'm not inputting script either on the third line

Included an image for my progress on my attempt for visuals
I made a Screenshot of the Eventpage, i believe that explains more than a thousand Words =).
Let me know if you need further assistance.
actorchangeghdkfi45.PNG

Edit:
I changed the Name of Switch 4 from Switch0815 to Switch 4 , to fix missunderstanding with the name of the switch and its id.
@Bex

Okay I think I understand the formula now (thanks for the name change btw that really helped get rid of my confusion regarding what I thought I was reading lol!!) but now my only problem seems to be executing it? I'm holding down shift on the square I designated for the event but for some reason nothing seems to be happening???

Edit: (I'm pressing Q in the last screenshot below)
Did you set the Trigger to Parallel?
If its on Parallel it should not matter where you press that Button on the Map.

Edit: You need to Press and Hold the Button in the current Setup.
Oh i had to make the picture big, now i see you got in on parallel.
but the other picture is hiding the eventpage conditions, i guess the error must be there.
or
Do you have a Event on Autorun running on that Map, or do you got a Common Event on Autorun running?
No parallel Event will execute aslong the Autorun is running.

Dont know what else could cause this.
The only thing I had checked on the event editor page is the walking thing (which I turned off and tested again to no avail). I also moved to a new game project to test this too (starting fresh so I don't have to worry about any autorun events getting in the way) and pressing Q does nothing for me ;w;

I don't know if this makes any difference, but I'm using a Mac computer to do this in. Hypothetically, the keys on a Mac shouldn't differ from a Windows computer (with the Q ket being shared between them of course according to the official site) but it's the only thing I can think of that might interfere since the code is correct but it's just the button that's not working?

(Edit: Also tried holding down the button too for five seconds time as well. Feel like five seconds should be enough but I could be wrong)
I guess you could change the Button from Q (Page Up Button) to Escape (Cancel Button) and retry the test.

Yes, i also guess its just that the page up button of rpg maker is not the q button on your keyboard.
You could start and try every button on your keyboard alternatively.

The code runs flawlessly on my end.
OH

I FIGURED IT OUT

Used the textbox message cheat and now I understood what I did wrong. I figured out that I got everything except the actor images correct and that everything was working except that.

Quickly googling "why is my actor image not changing" got me my answer: I didn't realize I was supposed to use the same actor (i.e. Harold) and merely change the character actor image instead of switching between actors (which for some strange reason is what I was interpreting was what was going on).
Looking back at your first image I realized I completely blanked over the fact I was using two different actors instead of just changing the actor images which explains why it wasn't working (because I was trying to impact an actor that I wasn't playing as).

So fgjhgfjh it turns out my mistake was using two different actors instead of just one of them for the entire event command. Testing it again with only the actor images changed gets me the exact result I wanted. Thanks so much for the help (as well as being patient with me ^o^)!!! I'm excited to be able to use this in my game now ^w^
Oh, I used other event as example and made a mistake not to clarify it, I'm really sorry.
Both process, mine and Bex's are built the same way, have the same principles (thanks to Bex for explaining with more details and more clearly). The difference lies in "is [button] pressed" x "is [button] triggered", both work and both have their values and it's just a preference on how you want things to run.

Common events and switches are different things, yes. You can see all the switches and variables in a event if you right click, "New..." and "Manage Switches" or "Manage Variables".

In my examples you'll need two switches. One for the common event and one to toggle if it's on or off (this is the flashlight one on the picture). They could be any, but not the same.
The switch for the common event is what you'll trigger to make the event running. Could be at the start of the game or only on the map transfers to the map you want it working (in this second case, you need to remember to turn it off when needed).
The second switch (I'll call it SS) is what will condition the button response. If SS is on, with will do x and turn the SS off. If it is off, it will do y and turn the SS on.

I'm sorry again to cause any confusion and I'll thank Bex again for explaining further.
Oh it was right infront of me on that Picture and i did not see it. My mistake, iam glad it works now.

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.

Original thread: https://forums.rpgmakerweb.com/threads/how-to-swap-actors-in-the-overworld-w-the-press-of-a-button-mv-solved-d.124520/