this is my first post. I recently started playing around with UE4 (I love it) and I still might get some concepts or some terminology wrong. If so, please correct me!
I am currently just playing around with the default plane flying game, trying physics, some new flight models etc.
Now, what I want to do is to add some sort of “air resistance”. Meaning that if you do not thrust, you lose a percentage of your speed per static time frame. That loss of speed is applied every tick. And since that loss is relative to the current speed (the faster you are, the more you lose) I couldnt figure out how to also connect it to the delta seconds so that, no matter the tick rate, if I am supposed to lose 10% per second, and I fly at 200 speed units for 2 seconds, I end up with 162 speed units.
In other words: How can I decrease a value in a relative way per static time frame in a dynamic (tick length is dynamic) tick system with that decrease always being the same.
If that loss of speed was static, meaning e.g. 5 units / sec instead of X% / sec, now that is easily figurable.
I hope I was able to picture the problem I am facing right now. If this is the wrong forum please move it or give me a notice.
Define your “Rate” of loss/gain like 10 speed units per second and multiply it by delta seconds. 10u/sec * Xsec, the seconds cancel out and you are left with your rate*delta time and that will give you the amount to add/subtract.
So for example:
10u/sec rate
1.337 seconds have passed between frames
10*1.337=13.37 units lost
This is very useful concept to grasp and understand because it will allow for you to make important things frame independent.
Going by what he described with “Now, what I want to do is to add some sort of air resistance,” I just gave him a primer 101 on how to use rates of change vs delta time. Though you know what, we can go even further with it and give it the real formula of F=k(v^2). Even better, we can expand that into ((air density * drag * area)/2)((velocity)^2). While we are at it, we can define air density and drag too and we may as well make sure to calculate a proper force for the craft so that we can sum up the net velocity vector after the drag friction is removed from the forward force. Oh wait, we will need to know the mass of the craft and MOIs of every part, then we can derive the proper model for how the craft will behave with respect to inertia.
At some point, you just draw a line in the sand and say enough is enough lol…
Again, I was just giving an example of Rate * Deltaseconds and not giving him a direct “Plug this in and solve your whole problem” answer. Rate can be some huge complex formula or it can be a simple linear rate. But yeah, I guess I was having a brain fart this morning and am guilty of not paying attention full attention.