This is the right place for it, right?
Well, I made a common event in my game that changed the player's graphic when a specific button is being pressed. Here is what I did, using event commands:
> Conditional Branch: The Z Button is Being Pressed
>>Change Actor Graphic: [Player], '$Graphic2', 0, (None)
>>Control Switches: [0001: Switch] = ON
Else
>>Change Actor Graphic: [Player], '$Graphic1', 0, (None)
>>Control Switches: [0001: Switch] = OFF
>Branch End
When I press Z, nothing happens. But if I change it to Up, Left, RIght, or Down it does work. The problem is that I don't want to use those keys, and the ones I want to use don't work! It doesn't have to be the Z key, but not the arrow keys. Is something wrong with it?
Strangely enough, the 'Z' button is not Z.
Hit F1 while playing your game and go to the Keyboard tab. I think mine is set as the default, and the "Z Button" is actually D.
If you want to use other keys that are not in that list, you will need a keyboard script.
I think Z in the program settings doesn't actually correspond to the actual Z key, they actually vary.
edit-Ah, can't beat out Shaz on the draw I guess.
Alright, I got it solved. Thanks guys!
FYI:
The buttons are named for the buttons on a gamepad, not for the letters on the keyboard. That's why the game reacts only to a part of the keys on the keyboard (no full keyboard unless you script it in) and why they need to be mapped to correct keys by F1-configuration.
OP your else case will be executed every frame, in combination with change actor grafic, this will cause lag or use most of your performance reserves.
Do it this Way:
> Conditional Branch: The Z Button is Being Pressed
> Conditional Branch: [0002: Switch] = OFF
>>Change Actor Graphic: [Player], '$Graphic2', 0, (None)
>>Control Switches: [0001: Switch] = ON
>>Control Switches: [0002: Switch] = ON
Else
> Conditional Branch: [0002: Switch] = ON
>>Change Actor Graphic: [Player], '$Graphic1', 0, (None)
>>Control Switches: [0001: Switch] = OFF
>>Control Switches: [0002: Switch] = OFF
>Branch End
Thisway the Change Actor Grafic command is executed just once when button is pressed and it will also execute just once when changing back. Checking a Switch if true or not costs much much less performance than executing this change grafic command every frame.
If your Button sometimes doesnt recognice the button press, than the cause is that events pages are not acualisized every frame, you can solve it like this:
Loop
> Conditional Branch: The Z Button is Being Pressed
> Conditional Branch: [0002: Switch] = OFF
>>Change Actor Graphic: [Player], '$Graphic2', 0, (None)
>>Control Switches: [0001: Switch] = ON
>>Control Switches: [0002: Switch] = ON
Else
> Conditional Branch: [0002: Switch] = ON
>>Change Actor Graphic: [Player], '$Graphic1', 0, (None)
>>Control Switches: [0001: Switch] = OFF
>>Control Switches: [0002: Switch] = OFF
>Branch End
1Frame Wait
repeat Above
Not sure what Switch 001 is doing in your Mechanic.