How do I set global variable based on key being down

Get help using Construct 2

Post » Mon Apr 21, 2014 6:43 am

Hi.

Trying something simple but i must be misunderstanding something.
I have a global variable i want to be set to 1 when the player is pressing down on the direction keys.
If they are not pressing the keys i want to variable to be set to 0.
Global Variable ("movekeys")

I tried the following.

If key (A) or (D) is down set variable to 1
I t hen inverted the If key (A) or (D) is down set variable to 0

However the variable stays on 0.

I then tried if key is pressed set variable to 1
If key is released set variable to 0

However the last option is not viable because if you switch between keys to quickly then the variable gets stuck on 0. As you pressed the key and released it and pressed it all in 0 seconds.
B
8
S
2
Posts: 163
Reputation: 1,115

Post » Mon Apr 21, 2014 9:16 am

Does it work for you?

Image
B
99
S
35
G
29
Posts: 3,139
Reputation: 28,421

Post » Mon Apr 21, 2014 1:33 pm

Thx. That did the trick. Much appreciated.
B
8
S
2
Posts: 163
Reputation: 1,115


Return to How do I....?

Who is online

Users browsing this forum: Artcadev, Iakkery and 30 guests