Jittery movement of Rigidbody attached to camera

,

I’ve tried everything I can think of, but I still get a horrible jitter effect when setting MovePosition of a Rigidbody to stay in front of the AR camera.

I’ve tried setting it to kinematic and also using Update vs. FixedUpdate, no matter what it still looks terrible (see video to see the jitters of the white ball as it tries to stay in front of the camera)

69ihfr

using the latest Unity and ARFoundation and ARKit plugins (but I’ve seen this issue even back when I was developing with VR in Unity, seems to be some kind of timing difference between XR provider updates and render updates? I have no idea)

Try changing the rigid bodys interpolation setting.

Try all three settings

Try using LateUpdate(), this way you’ll update the position of your pointer AFTER the camera position update.

I ended up having to set Interpolation to interpolate, and using LateUpdate
and it only looks smooth if isKinematic is on, it still looks jittery if using non-kinematic though (combined with rigidbody.MovePosition) any thoughts on how to fix this case?

Can you toggle isKinimatic only when the object is being moved/dragged by the camera, then toggle back? Or is that not functional for your setup?

yeah I can, I guess that’s fine

Haha, yeah i would say i feel as enthusiastic about the work around as you do.

Im not sure what’s going on there w the jitter. The other day i spent hours on a similar problem where the rigid body had jitter when moved only if the camera was also moving. Position was based off a camera raycast like i assume yours is.

I did everything possible as far as repositioning code to Update, FixedUpdate, LateUpdate, cinemachine update settings, non cinemachine at all.

In the end interpolation was the problem. And in my case interpolation = none was the fix (not quite the same as you).

This was not an AR app.

However i also have an AR app where i move and drag rigid bodys while moving camera and everything works just fine. Never had jitter in the first place. Id have to look but i think all the rigid bodys are default settings, which i think is interpolation none, and is kinimatic false.

Sooooo. I guess im not helping by saying all that but i dont know its almost like we have had the same problem, but the answer was the opposite for us

Any logic that you do in Update is a frame off.

You should try using OnBeforeRender.

1 Like

If you move an object using FixedUpdate(), use “rb.velocity = x” or rb.AddForce().

rb.MovePosition() is an instant teleportation, so it causes jitter problems when used in conjunction with FixedUpdate().