Hi, I'm trying to do as a "recharge" shot. Suppose the key to shoot is "A".
So I want to know how to check how long you've been pressing the A key, to see if the shot has to be stronger or weaker. I can not find how to do ...
I do not know if cycles, labels ....: |
How are you shooting?
If you have a parallel process checking for the key press, you can do this using a variable and a switch:
Name the switch "Is Shooting" and the variable "Shoot Strength". On your parallel process, add a conditional branch for the key press. Inside it, add another conditional branch: If the switch "Is shooting" is true, then increase "Shoot Strength" by 1. Else, set "Shoot Strength" to 0 and "Is Shooting" to false. On the "else" condition of the key press, add another conditional branch: if switch "Is Shooting" is true. Inside this switch you can do whatever you wanna do to do the shooting, this will be triggered when the player releases the button.
It will look something like this:
conditional branch: key press conditional branch: switch "Is Shooting" is ON increase variable "Shoot Strength" value by 1; else set variable "Shoot Strength" to 0 activate switch "Is Shooting" end conditional branchelse conditional branch: switch "Is Shooting" is ON // this will be triggered when the player releases the button end conditional branchend wait(10) // wait a few frames before checking again, you can change this value; If you do this, the variable "Shoot Strength" will be higher the longer the player presses the button.
Edit: Don't forget to turn off the switch.
tested the code and it works the way I want except for one thing ...
It is that for the shot to recharge the character MUST BE MOVING! If I'm pressing the button while the hero is still, recgara variable shooting will not increase ...
if there was a way around this, and would just like looking good.
Thank you very much for the help !!