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"

Timer vs real time

Hi! Im use timer for offset my pawn every 0.01 sec. Offset variable is 1000 0.01 (timer delta time). But if i set timer interval to 0.1 sec, and set offset var to 1000 0.1, my pawn moves faster! Why timer executions does not coincide with the real speed of time?alt text

Product Version: UE 4.17
screenshot-4.png (118.8 kB)
more ▼

asked Nov 26 '17 at 07:34 PM in Blueprint Scripting

avatar image

32 2 6 8

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

With times lower then rendering time timers might not behave correctly, because if i'm not mistaken it check timers on per frame basis, timers is good if you use bigger time spans that don't require precision.

You should use tick event for things like movement for max precision, remember that in real time games everything operates on frame per frame basis, so everything (you might find some exception specially if animation is played directly to rendering) that moves on world is operated by Tick event which executes on every frame cycle. It gives you delta time which is estimated time passed between frames. Anything you will multiply to that delta time will turn in to "value change/s" and value will change pricisly as much as engine allows.

If you want things to move in fixed intervals, you can also do with tick but it requires more math. divide delta time to interval and floor it so you got natural number, multiple delta value to it and apply it, subtract floored result of first calculation to delta time and keep result of that in varable and add it to delta time on next tick (in beginning of tick)

Note that in CPU there no sense of time aspecially when each CPU runs of different frequency and some even change that frequency on the go, you can only read time and make code behave accordingly to time passed, so real time in programming is just a illusion by extreme fast CPU execution times. Timers will only trigger when timer code is checking time, but there always a limit of how much timer clock can be checked and it's always irregular check interval as OS will not run your code on CPU all the time, not to mention engine it self is also busy doing other things it can't check time all the time. Thats why timers have limited precision and delta time is actually more precise time counting tool then timers it self.

more ▼

answered Nov 26 '17 at 08:55 PM

avatar image

35.7k 925 168 1102

avatar image maslenok Nov 26 '17 at 09:29 PM

Thanks for the expanded answer!

(comments are locked)
10|2000 characters needed characters left
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