In Ursina, how can I programmatically obtain the current FPS count as number (like extracting it from the fps counter in the upper-right corner)? I need this for phyiscs calculations in Ursina. I have thought about something like this:
from ursina import * app = Ursina() e = Entity(model="some_big_model_to_cause_lags.obj",texture="some_texture.png") def update(): print(app.get_fps()) # should print 60, 75, etc. app.run() # should print something like: 60 61 63 59 62 59 ... I would also accept app.step() in a loop and somehow get the time between each call.
time.dt. Is that what you're looking for? (1.0/time.dtwould then give you an instantaneous framerate — 0.33333 s/frame ≈ 30 frames/s). Generally though you don't want to use this number directly in a physics calculation, since variations in framerate can then cause inconsistency in your game logic/simulation. We'll usually accumulate this and run game logic on a fixed timestep. \$\endgroup\$time.dtinstead of1/time.dt. Now it runs perfectly at every fps. \$\endgroup\$