How to make physics work every time the same independently of FPS?

Hi, im Building a jet pack Flying game and depending on the level I play the fps changes , and the Physics too.
Im using add force, with delay, if the button is pressed.
Im using a 100 meter tall building as reference for both levels

One level I get 40 fps the other 80 fps.
On the 80 fps level, when i use the whole fuel the character get almost to the top
On the 40 fps level, the character pass 3 times higher.

Considering is going to be multyplayer and people will have diferent Fps, how to make it work independely of Fps?

thanks in advance
Sorry if im not clear english is not my native language.

make your “addForce” function take an input of “real force”, and in each frame, feed “real force” with result of: multiplication of “default force” and EventTick property called “Delta Seconds”.

explanation: “Delta Seconds” tells how much time has passed since the last frame; that time is a fair multiplier for your desired force

example (when default set to 7):

DeltaSeconds = 1: real force = 7

DeltaSeconds = 0.5 (double FPS): real force = 3.5

both result in force of 7 in a second.

1 Like

Turn on Substepping. It will cause you physics to run at the same rate regardless of the frame rate.
You should also use Delta Time for changing values like fuel expenditure on click-hold.

Thanks for the answers
Should I multiply every node related to rate for DeltaSeconds?
Im sending the blue print to make it more clear.

Should I multiply the: Amount lost (how much fuel is lost when is pressed).
Thuster Recharge (how long it takes to thrust again) is connect to delay and then loops back
Fuel regen (the amount its regen)
Fuel Regen Rate (how long it takes to regen again) is connect to delay and then loops back

Just to understand better how it works… How often a press button is called? the same rate as a event tick?

thanks again

Thanks for the answers Should I multiply every node related to rate for DeltaSeconds? Im sending the blue print to make it more clear.

Should I multiply the: Amount lost (how much fuel is lost when is pressed). Thuster Recharge (how long it takes to thrust again) is connect to delay and then loops back Fuel regen (the amount its regen) Fuel Regen Rate (how long it takes to regen again) is connect to delay and then loops back

Just to understand better how it works… How often a press button is called? the same rate as a event tick?

thanks again

Thanks for the answers Should I multiply every node related to rate for DeltaSeconds? Im sending the blue print to make it more clear.

Should I multiply the: Amount lost (how much fuel is lost when is pressed). Thuster Recharge (how long it takes to thrust again) is connect to delay and then loops back Fuel regen (the amount its regen) Fuel Regen Rate (how long it takes to regen again) is connect to delay and then loops back

Just to understand better how it works… How often a press button is called? the same rate as a event tick?

thanks again

instead of looping back, create a boolean variable to indicate whether to do the stage on the current tick, or not. also multiply it by delta time. basically everytime you hear a combination of words EventTick+add, you need a multiplication by delta time.

Thanks i think i got it to work with all the answers.
i am keeping for now the loop because is working. Is there a reason for using boolean with event tick instead of a loop?
just asking because im using so many events ticks so many times on the same blue print, with sequence. I have no idea how unreal works related to calling mutiple times event tick for diferente functions.

You should have one delta time node per equation for your button based action.

For example: OnAction > If ThrustFuel is greater than 0 > ApplyThrust > Subtract ThrustFuel by DeltaTime > Update Fuel UMG

because every tick has a new delta time (since the last tick) (tick=frame)
whilst loop is kinda unpredictable when it comes to the framerate. (in most cases loop iteration happens much faster than a frame)

oh and mark the question as solved please

thanks again!
where is the option to mark the question?
im new here im looking but cant find it the option

good luck in your path, remember to feed your motivation by the right environment :slight_smile:

1 Like