Start time with input

Hi i have a “time” HUD and i need it to start count when i Press “E” “F” (no matter)
Here is BLUEPRINT of the HUD.

One more thing, how can i add here a Trigger, for example when i overlap it the countdown STOP.??

You should use the timer functionality for this. Here is a link to the documentation

There are several built in functions you can use once you put a handle on your timer. You can easily set a trigger volume in the world and set it’s collision to overlap with your character, or whatever it is you want it to overlap with, and when the overlap occurs, you get the reference to your timer handle and either Pause the timer or Clear the timer.

Hope this helps!

That isn’t what i need .I don’t need to blow or firerate, or something like this,i have a simple countdown and i want it to start when i press “E” and to stop when pass the trigger.

Hi, there are several ways of achieve this 1 could be with a timer, but using what you got follow this steps:

1- First of all you need to set a Input Action Mapping to the key you want to bind the “StartCount” let’s say E. Go to Edit>Project settings>Input and add “StartCount” input mapping to E key.

2- Create an Editable boolean variable named let’s say ToggleStartCount, notice the “Editable” checkbox checked.

74479-2.jpg

3- Add a Branch node that reads that new variable between your Event Tick and the SET Time.

4- Open your Character Blueprint and add nodes that Set the new variable to true when E key is pressed

5- For the trigger stop part you need to add a trigger box to your scene, by default it will be named as “TriggerBox” if you have none

74482-5.jpg

Continue next comment… dont allow me to attach more imgs.

6- Again in your character blueprint add an OnComponentBeginOverlap to your CapsuleComponent (assuming you have one)

74487-6.jpg

7- Add nodes that set ToggleStartCount to False so it stops counting.

That would be all. Got it working here,

Sorry my english.

Cheers.!

There are several ways to do “Time”; however, for your needs, timers will be the most simplest function(s) to use. Do not take examples and documentation literally for what they used it for as they are generic use cases to show a basic example of how to use them. You need to be able to adapt from what they teach. Here is a very simple setup I made using a single timer to do exactly what you want. It took me a total of 5 minutes to setup:

On the controller:

Then, I simply put a Box Trigger in the map and created a blueprint from it that included this:

The example here will print the remaining seconds on the screen (using the tick function) to display the remaining time, rounded UP to the nearest second (FCeil). When the timer expires, it runs the event “Failed To Beat Timer” and prints that to the screen.

The box trigger will call the player controller, casts it to the custom player controller, where the timer and functions are, and then runs the event “Beat The Timer” which clears the timer (stops it) and prints to the screen that you beat the timer.

Hope this clears things up for you a bit!

Also note, I put this functionality into the player controller, which you can do and just have it send the information to your HUD to print. You could also just put the functionality into your HUD directly as I have here but you will need to make sure that “Block Input” is not ticked in the details panel of your HUD settings. You may also need to use the node “Enable Input” at the Begin Play of your HUD. Usually when you create custom controllers, it automatically blocks input to all blueprints so you need to Enable Input on the blueprints you want to have inputs on. Such as if you want to run the “E” key binding from the HUD. It is good programming practice however, to keep all your Input commands centralized; in this case, on your player controller, and have it send requests to the blueprints you want the key binding to affect.

It Works, THX a loot, but one more thing, when i overlap the Trigger the time is disappear , but i need it to stop but to be visible , to know what time is when the Timer stop.Plus i did some changes in BP programing.

Yes, that changes of yours are not drawing when ToggleStartCount is false you need to add some logic to the False Exec output of that Branch node. Look the attached image, it do almost the same in the false case but adds another branch node to check if time is > 0 wich means that count has already being started once and then draw the stored value without setting it again. Note that didnt add the macro not sure what it does but the logic should be the same.

Regards.

Glad to :slight_smile: cheers! Not sure how can you mark this as answered? Thanks!

Great! Save me :smiley: , Thank you very much. All work :).
Macro is logic of the Timer.

thank you for your help,appreciate it :slight_smile:

Because it’s the correct answer.it works

Hello everybody,

I want to start a progress bar of 60s when I launch a matinee with a key press (same key for the 2).

Alone, the progress bar works well but launch at startup…

I go until step 4 but my “cast to” is not working : “hudperso” does not inherit from “HUD”…

I am in the level bp, i have no character bp, i started from a blank project.

Can you help me ?
Thanks.