Welcome to the Oculus Developer Forums!

Your participation on the forum is subject to the Oculus Code of Conduct.

In general, please be respectful and kind. If you violate the Oculus Code of Conduct, your access to the developer forums may be revoked at the discretion of Oculus staff.

Physics slowdown with framerate?

silentslacksilentslack Posts: 21
Brain Burst
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!

Comments

  • vrdavebvrdaveb Posts: 1,596 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.
  • silentslacksilentslack Posts: 21
    Brain Burst
    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.
  • vrdavebvrdaveb Posts: 1,596 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.
  • silentslacksilentslack Posts: 21
    Brain Burst
    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.  
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    Does it help to set the following? Time.fixedDeltaTime = Time.timeScale / 90f; Time.maximumDeltaTime * 2f;
  • silentslacksilentslack Posts: 21
    Brain Burst
    What are we trying to do with: Time.maximumDeltaTime * 2f;?
  • vrdavebvrdaveb Posts: 1,596 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.
  • silentslacksilentslack Posts: 21
    Brain Burst
    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?
  • vrdavebvrdaveb Posts: 1,596 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.
  • silentslacksilentslack Posts: 21
    Brain Burst
    I have both Oculus & OpenVR added in Player Preferences but using OVRCamera rig and only Unity native VR functions.  If I remove OpenVR from the Player Preferences I still encounter the same problem.
  • silentslacksilentslack Posts: 21
    Brain Burst
    Just wondering if there is an update on this and whether anyone else has seen the same issue?
  • vrdavebvrdaveb Posts: 1,596 Oculus Staff
    We had an internal team with the same issue. They got around it by setting Time.maximumDeltaTime = 1f. If that doesn't fix it for you, we will have to wait until Unity can root-cause it and provide a fix.
  • silentslacksilentslack Posts: 21
    Brain Burst
    edited December 2016
    OK that did it!  I'm guessing there is a bug somewhere but that has solved it for me in the meantime.  Thanks!
  • AyfelAyfel Posts: 33 Oculus Start Member
    edited October 2018
    So for some reason I am seeing the Oculus Sdk in Unity changing my fixeddeltatime to crazy values like 0.0024
    No idea why, it kicks in randomly (not very often) but it breaks the game basically. Any idea what might be going on?

    P.S: Same game with SteamVR sdk not a problem btw
Sign In or Register to comment.