How to lock a key for a certain amount of time?
I have a Dash function which can be used by pressing the SpaceBar, I have a Bar that will go empty and refill so you can dash again. the problem is that if you press the key again, the bar will empty again and it will glitch. Is there a way to lock the spacebar for 3 seconds?
This is my Current Blueprints
Here is the Dash Function
Any Help will be deeply appreciated!!
P.S. the many copies of Set Percent was because the Progress Bar fills from 0.0 being empty to 1.0 to being full, so i couldn't figure out how to get a timer running and fill the bar in 2 seconds, i came up with this, which sorta works, but yeah... :D
asked Oct 16 '14 at 06:54 PM in Blueprint Scripting
Hey there, this is a way too complicated setup for what you want to achieve. Have a look at the DoOnce or Do N inputs. They are basically nodes that only function a certain number of times. E.g. if you want to dash, you put a DoOnce node after the Dash Input node. It won't fire after the first time until you reset that node. To reset it you can just use a custom event that fires once the dash is complete.
DoOnce is useful for dash-like events. Do N is useful for double-tap events like double jump or the dash in UT2004 (double pressing any movement key would make your character dash in that direction).
Here is a sample:
answered Oct 16 '14 at 07:30 PM
Even though @alperenakyuz solution will work perfectly let me give you another way you could do this:
Since you can "Set Percet" there has to be a "Get Percent" as well so you can use that to check if it's 100 or not.
If you press the spacebar empty it to 0 percent.
Also I would recommend not doing the the refill bar like you have (you probably figured that this is a bit messy) but rather use the "Delta Time" variable.
This variable will provide you with how many seconds have passed since the last tick (usually something like 0.0something). You can use this to multiply the delta time by the rate at which you want it to refill per second and it will give the the result you're looking for.
You can then also check if the bar is full and as long as it isn't add the value and all of this with under 7 nodes!
Just a very minor thing to remember. Check if it's going over 100%. If so just set it to 100 and it should not do anything else. I'm not entirely sure what happens if you go over 100%... it might just extend the bar further.
answered Oct 16 '14 at 09:43 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here