# Program a game that requires pressing alternate keys

**URL:** <https://forums.unrealengine.com/t/program-a-game-that-requires-pressing-alternate-keys/430672>\
**Category:** Blueprint\
**Tags:** running, unreal-engine, Blueprint, question\
**Created:** [July 31, 2018, 7:34pm UTC](https://forums.unrealengine.com/t/program-a-game-that-requires-pressing-alternate-keys/430672 "2018-07-31T19:34:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_98d661d2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_98d661d2](https://forums.unrealengine.com/u/anonymous_user_98d661d2)\
**Post date:** [July 31, 2018, 7:34pm UTC](https://forums.unrealengine.com/t/program-a-game-that-requires-pressing-alternate-keys/430672/1 "2018-07-31T19:34:59Z")

</div>

Hello everyone,  
Me and a friend of mine are creating from scratch a sprint game, where the player would have to press keys in an alternate/interspersed way (ex: left key, right key, left, right…), otherwise he would fall. The faster he can press them, the faster he will run.  
The problem is we have very little experience in blueprints (and our C++ ability is inexistent) and don’t have the slightest idea on how to do it.  
Every suggestions are welcome.  
Thank you guys!

In case you need some gaming reference, we plan on doing something like this! (Sprinter, Derby Racing and QWOP)

> **[Sprinter Jogo -Jogue online no Y8.com](https://pt.y8.com/games/sprinter)**
>
> Joga Sprinter, o jogo online grátis em Y8.com! Clique agora para jogar Sprinter! Diverte-te com os melhores jogos relacionados com Sprinter.

> **[Derby Racing Jogo -Jogue online no Y8.com](https://pt.y8.com/games/derby_racing)**
>
> Joga Derby Racing, o jogo online grátis em Y8.com! Clique agora para jogar Derby Racing! Diverte-te com os melhores jogos relacionados com Derby Racing.

> **[QWOP](http://www.foddy.net/Athletics.html)**
>
> Athletics Game

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [July 31, 2018, 7:51pm UTC](https://forums.unrealengine.com/t/program-a-game-that-requires-pressing-alternate-keys/430672/2 "2018-07-31T19:51:57Z")

</div>

So the player character already has a “max walk speed”, you could easily modify this variable. Holding down the “forward key” would allow the player to run straight ahead. Then you can choose 2 keys of your liking say “F” and “H” for example. And start with “F” after pressed have a branch node that checks, a boolean that sees if “H” was pressed, have this default set to true. Then after this branch off the true, set “Was H Pressed” to false, set a second boolean “Was F Pressed” to true then add 5 to the “max walk speed” and set this value. Off the false have a node that sets “Max walk speed” to default value like 600 whatever you like. Do the same thing for “H” with the branch except switch the boolean variables around so it would check to see if “F” was pressed. If true increase walk speed. This way the player must alternate between the 2 keys and as long as they do it properly the player will run faster. If they mess up he goes back to default speed. You can also add a retriggerable delay node or something to make the player have to press the buttons within a certain time frame else the speed is reset to default.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_98d661d2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_98d661d2](https://forums.unrealengine.com/u/anonymous_user_98d661d2)\
**Post date:** [August 1, 2018, 6:09pm UTC](https://forums.unrealengine.com/t/program-a-game-that-requires-pressing-alternate-keys/430672/3 "2018-08-01T18:09:35Z")

</div>

Hmm, it makes a lot of sense. Thank you very much!!!
