Press key trigger problem
Feb 21, 2019
Hello everybody!
I've been running tests to make a course with a feeling of a game, more interactive and fun. I want a character to walk through a scenario, and after watching many helpful tutorials and gathering a bunch of inspiration from the community, I started the test and now it's stuck.
The character must walk when the user presses the right key - it's a gif animation, moving through a motion path animation, triggered by the key pressing.
However, if the user keeps the button pressed, the character wont stop walking, and eventually will leave the slide! Is there any way to "block" the movement in case the right button is pressed for a longer time?
I've uploaded the file with the problem, I hope it can clarify a little bit!
Thanks in advance :)
7 Replies
Hi Marina!
I really like the design of your slide – nice work!
I haven't seen a way to prevent the character from moving off of the slide if the learner presses the Right key too many times, but perhaps folks in the community can share their experience with this! I'm interested to see the ideas they'll offer. 😁
Hello Marina,
You could create a number variable that keeps track of the characters position. Each time the right key is pressed you add one to the variable.
Then add an If to your triggers checking the value of the variable.
Here's an example.
Thank you! I just put together some cute images from the internet and a default animation from Animate :)
I'm looking forward for new ideas too!
I see the character doesn't leave the slide anymore, which helps me a lot already, thank you! :)
The thing now is, if the user presses the right key repeatedly or just keep the finger holding down the key, the character will "run" to the end of the slide now, and the animation won't be fully played. Any ideas on how to solve this part?
See attached a slightly different version that also accounts for the situation when a user keeps the key pressed. I use variables to indicated when the key is pressed, when the animation is complete and when the right edge of the screen is reached. Based on these variables I stop the animation and change the character state.
Michael, this is perfect! And I just found out that the use of the variables while the key is pressed it's also useful not only for this project, but also for another one we have going on here :) Double win!
Thank you very much!
Marina, great to here that my suggested workaround does the trick. Good luck with your project(s)!
This discussion is closed. You can start a new discussion or contact Articulate Support.