I have a problem with the combination of Cinemachine and parallax effect in 2D. I hope for your experience and advice.
I have a car moving along the road (2D).
The camera follows it via Cinemachine Virtual Camera.
The background with the parallax effect is implemented manually, via a script based on Update() and transform.localPosition.
Behavior:
If the camera has Update Method = LateUpdate, and Blend Update Method = LateUpdate, then the background is smooth, as it should be, BUT the car starts to twitch.
If you switch these methods to FixedUpdate or SmartUpdate, then the car moves steadily, BUT the background starts to twitch.
I tried Lerp, different types of tracking, WaitForEndOfFrame - it doesn’t help.
Question:
What is the best way to sync parallax with Cinemachine?
Is it possible to have both the background and the car look smooth at the same time?
Since parallax is calculated based on camera position, you have to run that code after Cinemachine has positioned the camera. There are two ways to do this:
Install a handler for CInemachineCore.CameraUpdatedEvent and do the work there, or
Do it in a script’s LateUpdate, and set the script’s execution order to be after CinemachineBrain
I’ve followed the advice and added the parallax update to the CinemachineCore.CameraUpdatedEvent using AddListener as recommended. Here’s the updated part of my code:
Unfortunately, I still see jittering on static background elements when the camera follows the moving car.
To clarify:
The car uses physics (WheelJoint2D + Rigidbody2D), and interpolation is set to Interpolate.
The Cinemachine Brain’s Update Method and Blend Update Method are both set to LateUpdate.
Parallax layers are updated only when the camera is within sector bounds.
Parallax logic is called after the camera moves (via CameraUpdatedEvent).
All static elements are non-physics objects and are not parented to moving objects.
Important note:
In the Editor, everything looks smooth — no jitter at all.
However, when I run the build on an actual mobile device (Android), the jitter becomes clearly visible. Static background elements seem to “vibrate” or “shimmer.”
Any idea what could cause this platform-specific issue? Could this be related to mobile rendering, refresh rate mismatch, subpixel precision, or something else entirely?
Really appreciate any further suggestions — thank you!
I see you tagged it as 2022-3 but I want to double-check; may I ask what version of Unity you’re using here?
There was an issue where interpolation wasn’t giving good results when rendering was restricted to much lower frame-rates. Because this is only happening on Android, I’m wondering if it’s fixed at 30 FPS and it relates to that. In theory you might be able to simulate that by setting the target frame-rate.
Of course, it might not be related at all as this couldn’t be reproduced on 2022-3.
If you turn-off the camera follow on Android and it’s smooth then the Transforms (and interpolation) is working fine so it’ll be related to something about the camera following mechanism.
Finally, you mentioned the (singular) Rigidbody2D is using interpolation however I’d expect there to be multiple Rigidbody2D being used here as opposed to only one as it’s a car. Can you check which body you’re following and that it is in deed using interpolation and that you’re not modifying the Transform here which can cause all sorts of problems with physics (I presume not because you’re seeing smooth movement outside of Android).
Yes. I solved this problem. The problem was solved by increasing the number of frames on the phone. But I tried to change the settings in the cinema machine and this did not give an effect in my case