cancel
Showing results for 
Search instead for 
Did you mean: 

Physics slowdown with framerate?

silentslack
Explorer
Hi,

Developing in Unity 5.4 - I've found that physics calculations slow down relative to the frame rate, is this expected?  There seems to be some other slowdown such as animation of texture sheets.  

When using the Vive the framerate hiccups don't seem to mess with the physics but with Oculus things go all floaty when the framerate dips.  Is there any way to prevent this or is it likely I'm doing something wrong?

Thanks!
14 REPLIES 14

vrdaveb
Oculus Staff
Unity updates physics the same way for Rift and Vive. They occur at a fixed rate in simulation time. If your app is really performing poorly, we drop its framerate to 45Hz and use ASW to make it track at 90Hz. You can disable that with CTRL + Num 1 as a test.

silentslack
Explorer
You're correct, the app is dropping to 45 fps and when this happen the physics goes floaty.  I've tried to disable ASW but not sure if I'm doing it correctly?  Do I have to do CTRL + 1 (is it numpad1 or just 1?) in Oculus Home or in Unity?  Is there any way to see that ASW is turned off?  Should ASW affect physics in this way?  When I throw an object up into the air if the framerate is at 45 fps it falls at half speed.

vrdaveb
Oculus Staff
Do I have to do CTRL + 1 (is it numpad1 or just 1?) in Oculus Home or in Unity?

CTRL + Numpad 1 should work from anywhere.

Is there any way to see that ASW is turned off?

Not directly. It's being added for a future release. For now, you will have to keep a frame counter and infer that ASW is active when the frame rate is 45Hz.

When I throw an object up into the air if the framerate is at 45 fps it falls at half speed.

Is this with a plain, non-kinematic Rigidbody? If so, it sounds like a bug in Unity. What is your fixed timestep size? If the rendering frame rate gets cut in half, Unity should run twice as many fixed updates (and physics updates) per render frame. So if you write a MonoBehaviour and implement the FixedUpdate function, it should run the same number of times per second.

silentslack
Explorer
Fixed timestep is 0.01111111.  Yes, non-kinematic Rigidbody with nothing special going on, just throwing it up and watching it fall.  

Things are fine on the Vive.  Only seeing floaty physics runnng Oculus when it drops to 45fps.  

vrdaveb
Oculus Staff
Does it help to set the following? Time.fixedDeltaTime = Time.timeScale / 90f; Time.maximumDeltaTime * 2f;

silentslack
Explorer
What are we trying to do with: Time.maximumDeltaTime * 2f;?

vrdaveb
Oculus Staff
Oops, that should read Time.maximumDeltaTime = Time.fixedDeltaTime * 2f;
That way physics will know to integrate 22.2ms instead of 11.1. In theory, dropped frames shouldn't impact physics integration, but it may be in your case, which we would need to approach Unity about.

silentslack
Explorer
No difference on setting the timescale manually.  Still getting slowdown physics.  I'm running 5.4.1f1, could an update affect things?  I'm pressing CTL + 1 but I'm not seeing any difference.  Physics feels totally fine on Vive.

(video link - when I enable the movement portal thing it slows down to 45fps)
https://dl.dropboxusercontent.com/u/49858553/PrivateEye/Videos/SlowPhysics.mp4

I can't imagine I'm the only one to notice this if it's due to ASW?

vrdaveb
Oculus Staff
Thanks. I assume you are using Unity's "Oculus" VR device and not the OpenVR device. We'll take a look at the physics integration code and see what's causing this.