Search Unity

VR - Rotating camera issues / Stutter

Discussion in 'AR/VR (XR) Discussion' started by JamesWjRose, Jun 10, 2020.

  1. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    I have a city scene and the player is in a car. When the game starts the player can look anywhere and move their head at any speed and everything is fine. However, no matter what code I use to turn the car (addforce, Quaternion.RotateTowards, etc) I get a noticeable to horrible stutter effect. I am using the XR Rig, or not. I have tried parenting it to the "Car", or not (with another script to force the camera to follow the car's position)

    Obviously there must be a way to do this and I am an idiot for not knowing it... so, any hints?

    Thanks kindly and I hope your world is going well.
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    No, it has nothing to do with that. (Parenting the whole rig under the car would be the standard setup.) Something else is causing you to drop frames when you turn the car. You'll need to track that down using the usual profiling tricks.
     
  3. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    I do appreciate the info... however, why does the issue only happen when turning the camera/vehicle. and not when I turn my head?

    I will take a peek at the profiler tomorrow, so thanks for that thought.
     
  4. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,933
    It sounds like you've got position fighting - e.g. if the VR rig is updating on physics thread, and you're changing its position in Update (or vice versa).

    This is core Unity stuff, so you probably know it already, but: you absolutely always must co-ordinate your use of Update, FixedUpdate, and LateUpdate - they are incompatible, and will cause problems like this - and you must similarly co-ordiante / avoid mixiing: transform.position / rotate, rigidbody.translate / rotate, etc - again: they are fundamentally incompatible.

    If one script (even a Unity XR script) is using one, and another is using another, everything's going to go badly wrong, nothing to do with VR.
     
  5. JamesWjRose

    JamesWjRose

    Joined:
    Apr 13, 2017
    Posts:
    687
    Thanks kindly. I will look into that as well.

    The last few days has had me reviewing this info in the Profiler. I'm mentioning this to you, and in case anyone else sees this in the future. I have a script that creates a collection of hover cars as entities, and moves them via a Job System. Thing is, Profiler shows Scripts (within the CPU Module) as taking the BULK of the time, and showing 15 to MAYBE 30 fps. So I attempt to track that down (new to Profiler) and the odd thing is, when I remove all the vehicles from the script and replace them with one "vehicle" prefab that is two cubes, the issue with frame rate, in the Profiler, as I have not attempted to see if this resolves the issue in VR... baby steps. It's just odd that polygon count is showing up as a scripts issue.

    I will report back when I know more.

    Again, thanks for the info. Have a great week