[Closed] Is there a once per second event trigger?
I am trying to create an in-game clock system that is separate from the default system because the game world will run at a different time rate than the real world. In doing so, the baseline to establish the clock is to establish the minutes and seconds. Getting the seconds set is easy enough:
The problem comes in when I try to get the minute value. As you can see in the BP graph, the ClockSetMinute function is called after the seconds are set. As you can see in the next three images, all the flow control BPs will pass multiple outputs from an integer value because the Event Tick is firing multiple times per second. Even using the Do Once blue print does not keep this from triggering multiple times.
In this graph, the first branch should only fire if CurSeconds == 0, but since it is receiving multiple event triggers at sub-second intervals, it is going to fire multiple times within the 1 second where that statement is true. I added the DoOnce node, but as you can see in the graph, it is firing way more than once.
I guess the biggest question is, is there a way to get an event trigger that ONLY fires once per second or once per N seconds?
asked Nov 05 '14 at 07:47 PM in Blueprint Scripting
The question has been closed Dec 29 '14 at 06:25 PM by RAVaught for the following reason:
The question is answered, right answer was accepted
event tick() returns deltaSeconds, so if you add that to a counting float every tick, whenever that float gets greater than 1, you can subtract 1 from the count and allow blueprint flow to execute. this will result in execution once per second.
answered Nov 05 '14 at 09:26 PM
You are looking for timers. If you right click and type timer into the context sensitive menu you can get the timer node, which will allow you to set a specific interval and name the timer. Creating a custom function with the same name will create a timed event that fires off once every x seconds, where x is the number you chose.
answered Nov 05 '14 at 09:10 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here