x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

How to lock a key for a certain amount of time?

Hi!

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

Dash Bar alt text

Here is the Dash Function

alt text

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

Product Version: Not Selected
Tags:
dashq2.jpg (536.2 kB)
dashq.jpg (422.3 kB)
more ▼

asked Oct 16 '14 at 06:54 PM in Blueprint Scripting

avatar image

germ1389
20 8 10 13

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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:

alt text

dash.png (92.4 kB)
more ▼

answered Oct 16 '14 at 07:30 PM

avatar image

alperenakyuz
2k 62 24 110

avatar image germ1389 Oct 22 '14 at 09:37 PM

I tried the reset code, but it keeps restarting the code. it doesn't entirely work.

avatar image germ1389 Oct 22 '14 at 09:38 PM

Oh, no wait, the DoOnce is where the Dash function is, sorry my bad! :D

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

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.

more ▼

answered Oct 16 '14 at 09:43 PM

avatar image

Erasio
5.9k 291 86 293

avatar image germ1389 Oct 22 '14 at 09:34 PM

I know the dash bar is a bit too messy, is just that i haven't found how exactly to achieve it. Now, you're onto something, i would multiply the delta time for each dash time to record that time?? I'm a bit confused. The Bar does fill when you reach 1.0. the idea of the dash is to give 2 seconds of cooling off. i locked the dash function for 2 seconds, if you press it, the bar goes to 0.0 (the begging of the dash cool-off), then somewhat gradually using delays reach to 1.0 by adding fractions of a float such as .23 after .05, fill .54 and so on.Back to the subject how would you express the 7 nodes in Blueprints? keep in mind that the UMG Functions can't use any tick events. So far, that's been my experience.

avatar image Erasio Oct 22 '14 at 10:25 PM

UMG is not a replacement for your HUD.

You can't just use your UMG class as HUD and you shouldn't. Usually you would use several once for the specific job they do (Menu, ingame menu, HP and other player stats, Gamemode stats (for example points of your team), etc.).

So you can just call a function inside of your UMG from your HUD each tick which updates your bar if it is not already full.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question