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"

Time and framerate independance

Hey guys,

I'm new to the engine and my knowledge is probably inaccurate, so I'm not completely sure what the question is in the first place. I'll give you a brief description of what the problem is:

Trying to create simulations of missiles, and precision in timing is rather important (or my stuff misses by a few hundred meters). I'm trying to create the simulation to be frame-rate independent. Here the available information seems to be a bit conflicting.

It's being said that "Apply force" is frame-rate invariant, and with the following setup, it does indeed perfectly counteract gravity, regardless of frame rate. alt text

However, if I want to apply a force over time, I'd assume I use a timer: alt text

Assuming that 'time' itself is frame invariant, I'd think the later case should produce the same result. However, depending on the timer frequency the amount of force applied actually changes, and setting a -G acceleration on an object with 1kg mass, does not make the object hover.

Similarly, if I use a timer to fire an otherwise 'good' (supposedly tick invariant?) thruster for a brief time, like this: alt text I get a massive invariance in the force being totally applied. (In the above example with a force = 8000, time = 1, the 1 kg object without linear damping reaches a maximum altitude anywhere in between 1500 and 2400 meters.)

This makes me think that either 1. apply force is actually not framerate-invariant, but it's broken in the same way as gravity, so when used together they appear to work correctly. 2. or time itself is not framerate-invariant?

The second case seems to be the logical explanation that I can think of, but that would defeat the point of using timers in the first place. If a unit of time elapsed is proportional to the number of ticks being calculated instead of the actual time elapsed I fail to see how in-game time is supposed to be used (practically timers are simple tick counters that fire with the ticks?).

I might be missing something here, so first of all what could be the actual problem? Given that, what do you think is a suitable workaround? (to make sure the amount of force applied is always constant, and the time period is close to constant)

Product Version: UE 4.7
Tags:
setup.png (67.2 kB)
setup2.png (106.3 kB)
test.png (182.1 kB)
more ▼

asked May 26 '15 at 07:33 PM in Blueprint Scripting

avatar image

ELFoglalt
16 1 2 4

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

2 answers: sort voted first

Although I don't have a complete solution to the problem, further investigation revealed that the question at hand is more complex than I originally thought, and should probably be investigated in smaller parts. Therefore the original question is obsolete, and I'm marking it as resolved.

more ▼

answered May 28 '15 at 03:17 PM

avatar image

ELFoglalt
16 1 2 4

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

Force is time rate invarient, the timer is not. Multiply your (current seconds * delta time) to get a frame rate indepedent time value, and pump that into your timer. Also, bear in mind that even if you force & timer are time rate independent, your actual movement updates may not be. Anywhere you are going to be using a time variable, you need to multiply it by delta time to get your actual framerate independence.

more ▼

answered May 26 '15 at 07:40 PM

avatar image

RAVaught
699 44 28 68

avatar image ELFoglalt May 26 '15 at 08:46 PM

Could you please provide an example of this being implemented? I'm not sure how I'm supposed to call the timer, as delta time seems to be a constantly changing value. The closest thing I found would be "get world delta seconds" but that seems to return zero if it's not requested as part of an "Event Tick" event.

avatar image RAVaught May 26 '15 at 11:05 PM

https://answers.unrealengine.com/questions/38798/how-to-use-delta-time.html https://answers.unrealengine.com/questions/227383/working-with-delta-time-force-and-rotation.html

There is a better explanation of Time*deltaTime there (including images). Also, let me restate something. The timer, to my knowledge, is based on the tick rate. Anything that affects your tickrate would affect your timer. As a possible solution, if the timer is not working right, you could also :

get seconds node get delta seconds

time = seconds * delta seconds (returns framerate independent time)

There is a lot you could do with that, depending on the level of precision you need. You could pipe the result into a modulo node with the modulous being the value you had set on your timer. Floor the results and check each tick to see if the result = 0, if so, fire your event. Not as straightforward as timers, but it is framerate independent(mostly).

Also something to look out for: https://answers.unrealengine.com/questions/89541/does-adding-deltatime-to-deltatime-per-tick-work.html

avatar image ELFoglalt May 27 '15 at 10:20 AM

Thank you very much for your answers, seems like I've got to a point where I understand what my problem is. ^_^

If timers were in fact tick rate dependent, that would explain why the method on the 2nd blueprint doesn't work. Based on my internet searches I had the same initial conclusion as you have right now, but this still seems to be conflicting with what I see in-game. Since this was still bothering me, I've decided to run some quick tests with timers: alt text

On short terms, timer times and delta time seems to stay consistent.

(If UE4 runs for a longer period the error seems to increase (last column), implicating that what you are saying is in fact true, and I'm just being a stubborn idiot right now. On the other hand, I noticed that if I run more time-consuming calculations inside the timer, it tends to lag behind, which makes me think that the "repeating" part of the timer is fired after the given function has returned, and not immediately after the timer has expired. This would explain why the error increases over time, while the timers are actually still tick rate independent.)

If the timers are tick rate dependent, the only way you could achieve a tick rate independent simulation would be constantly referencing system time, which makes little sense to me. On the other hand, if we assume that timers are not tick rate dependent, I'm clueless why the 2nd implementation works the way it does.

This would be probably easier if I knew how exactly these things are implemented in the c++ code, but my knowledge regarding handling something as big as the engine is failing me, I have no idea where to even start looking. We deviated quite a bit from the original question. Should I maybe re-phrase the original question to reflect what I'm interested in?

uttesttime.png (448.7 kB)
(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