Stuttering during rotation in VR. Proper method for player turning/rotation in VR?

I am making a hover race game in VR, however I am having an issue. I found this set of videos from Unity about a hover racer and used it. It adds a force to the RigidBody to turn and to move. I get the value of this, however the thing is when the vehicle turns there is a bit of stuttering to the view.

When I am just standing there and move my head back and forth, there is no stutter. It’s when the rotation code, seen below, runs that I get this annoying stutter. This only occurs in VR. I created a testbed scene with a new camera and only this code (as well as the necessary components to show the scene in VR) to insure that it’s not some other influence.

So, before I started trying other turning mechanisms I thought I should ask if there is a standard for movement in VR. Since these are cars obviously I cannot use teleportation, I need continuous moment. Thoughts?

Tried this in Update, FixedUpdate and LateUpdate. Issue persists in all.

This happens on all version in the 2019 series as well as the current release of 2020

EDIT: Here is the camera setup: Imgur: The magic of the Internet

float rotationTorque = (playerInput.rudder * rotationSpeed) - rigidBody.angularVelocity.y;

rigidBody.AddRelativeTorque(0f, rotationTorque, 0f, ForceMode.VelocityChange);

float sidewaysSpeed = Vector3.Dot(rigidBody.velocity, transform.right);

Vector3 sideFriction = -transform.right * (sidewaysSpeed / Time.fixedDeltaTime);

rigidBody.AddForce(sideFriction, ForceMode.Acceleration);

Probably in the camera code. Put the physics in FixedUpdate and the camera tracking code in LateUpdate may help out the stuttering problem.

Thanks, but the ONLY code for turning the camera parent is stated above. That code is in the FixedUpdate of the parent ; “XR Rig Follow” See this image for details on the XR rig: https://imgur.com/a/XLfBMiB

I made this simple scene to minimize outsize influence. So… what am I missing?

Thanks kindly for taking the time. Have a great week

I only ever get stuttering when I used physics and my camera manipulation was not in LateUpdate…just sayin’. Take it for what it is worth.

1 Like

you need to set the physics timing of your project to match the VR headset screen frequency or exceed it, since the fixed update is not tied to framerate but to a fixed time lapse.
try with 0.012 in the Time setting on the project properties.

1 Like

I will check that out. Thank you very much.

to fine tune it, use this formula:
Fixed Time Step = 1 / headset frequency
For the Quest, it’s 72hz
for the oculus Rift S, it’s 90hz
For every headset it can be different.
You can check the screen vertical frequency using this.
Also, you can set the fixed time step by script using Time.fixedDeltaTime = 1f/frequency

3 Likes

You may also be able to use interpolation on the Rigidbody, but I don’t know if that’ll introduce other issues.

Camera tracking code should be done in LateUpdate.

Physics run at different framerate and that framerate cane be LOWER than screen refresh rate.
By default, by the way, it is running at 50 fps, and compared to 90, 80 or 75Hz refresh rate of VR, yeah, it is going to stutter. So either don’t use physics code for camera, or configure physics framerate to match that of your headset.

2 Likes

Ah, ok. I think I get your point. This is an odd situation when dealing with racing games. I will have to think about the entire process. Thank you for the info