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"

[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:

alt text

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.

alt text

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.

alt text

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?

Product Version: Not Selected
more ▼

asked Nov 05 '14 at 07:47 PM in Blueprint Scripting

avatar image

704 44 28 68

avatar image eXi Nov 05 '14 at 07:50 PM

Maybe a delay node that is set to 1 second? :X

avatar image RAVaught Nov 05 '14 at 10:28 PM

Using a delay node had the same failure. The millisecond burst would cause a corresponding burst delayed by one second.

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

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

2 answers: sort voted first

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.

more ▼

answered Nov 05 '14 at 09:26 PM

avatar image

9.6k 320 205 450

avatar image RAVaught Nov 05 '14 at 10:29 PM

That worked perfectly! Thanks. I still think a hard-coded 1PPS (one pulse per second) function would be a useful addition to the BP nodes collection, though.

avatar image JohnsciXzKutor Aug 03 '15 at 03:51 PM

Maybe you can try also using delay Or I think if thats failed. My idea is in C++ there is what you called modulus so give it a try a modulus 30 is one second

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

Hi RAVaught,

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.

more ▼

answered Nov 05 '14 at 09:10 PM

avatar image RAVaught Nov 05 '14 at 10:31 PM

I knew about the timers, but I was doing this as an experiment to see if it could be done mathematically with the normal BP's using the delta time. The purpose was to create a simple to implement Clock BP that would allow designers to set up their world specific calenders as quickly as possible. Omnicypher found a great solution to it. :)

avatar image 8BitGate Aug 26 '15 at 08:44 AM

Adam that solution worked fantastic. I made EventBeginPlay setup a timer looping every 2 seconds, then made a function of the same name to perform a command. --Thanks~!

avatar image callmeEarly Mar 29 '17 at 02:50 AM

However, timer is not perfect (and almost useless to me) since it CANNOT take any parameter. Says, there is very possible to fire the same timer (a function/event) before the earlier timer completed, the variables in the loop will be mess up. So, gonna figure out a way to keep the references for each trigger, and that would be the hardest part here, IMO.

Updated: I found that I could create a blueprint (actor component) to do the timer event inside there, and I can pass references (variables/how long the timer should activate) to that component, so a copy of references will be created every time when I added this component and won't be mess up with the next one during it fires again. Hope this helps someone.

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

Follow this question

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

Answers to this question