- Home /
Jitter on Object with Rigidbody
I have an Rigidbody (Car) with a Camera attached to it. The car drives using Forces and an Angle on WheelColliders (motorTorque, BrakePower, SteerAngle). These values are only manipulated in the FixedUpdate Method. When I drive around in the Scene, temporary jitter effects occur. It seems it is not related to specific places in my scene. The one moment it runs fine & smooth and then for a short time, there is a lot of jittering in the Scene (especially noticable for objects that are near the camera). It doesn't matter whether it is a static (street sign) or a dynamic (another car) object. It appears like the game runs with 20 FPS, but the Profiler and my FPS Module tell me that Frames are around 100+.
Another weird thing (I believe it is the same problem) - when the game runs with vSync on a similar thing happens. It runs fine sometimes, and then out of nowhere, the game looks laggy, but the FPS count is going up (and more importantly - Frametimes aren't capped of by vSync and were varying every Frame - between 70-90 what should have been just 50).
I've tried several interpolation configurations (player only, player and other moving objects, etc).
Any guesses or suggestions what I should do next?
We have exactly the same issue and have filed a Unity bug report (I suggest you do the same to show we are not crazy!)
I can recreate this in the most bare boned project with a cube falling in front of a camera or a 2D image moving. I'm pretty confident its a Unity issue.
One thing I've done to test is have 2 white squares that turn darker as the FPS drops, the first is current delta and the second is the lowest delta time over 0.5 seconds. In our tests the first square appears to always be white but the second one shows flashes of grey.
As for fixing it, I still have nothing :(
This btw is the code for testing the squares:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class FPSBlip : $$anonymous$$onoBehaviour
{
public Image image, lowestImage;
double const60 = 1.0 / 60.0;
float lowest = 1;
void Start()
{
StartCoroutine(Reset());
}
void Update()
{
float value = Time.deltaTime / (float)const60;
image.color = new Color(value, value, value, value);
lowest = $$anonymous$$athf.$$anonymous$$in(lowest, value);
lowestImage.color = new Color(lowest, lowest, lowest, lowest);
}
IEnumerator Reset()
{
yield return new WaitForSeconds(0.5f);
lowest = 1;
StartCoroutine(Reset());
}
}
Just pass in two Image's (the new Unity UI one) with nothing in their source slot
A lot of times I get rid of jitter by putting the camera follow in late update