Create a smooth camera without jittering/flickering in 2D
I searched a lot and I can't find the answers, I have a Cinemachine camera, my character and a parallax, my parallax moves smoothly in the Scene view so I can conclude that the problem is in the camera . If I remove the cinemachine and just make the camera follows the player, It jitters with it and the issue is "gone" : https://imgur.com/a/wFnQt
but if I smooth the movement, with Cinemachine or not, the parallax starts flickering because of the camera and the player movement: https://imgur.com/a/yaRLh
I've already tried:
rb2d.MovePosition(rb2d.position + movementVector * speed * Time.smoothDeltaTime);
//transform.position += new Vector3(input_x, input_y, 0).normalized * speed * Time.deltaTime;
//rb2d.velocity = new Vector2(Mathf.Lerp(0, input_x * speed, 0.8f),Mathf.Lerp(0, input_y * speed, 0.8f)).normalized;
rb2d:
Interpolate/extrapolate
PlayerMovement:
FixedUpdate
deltaTime
fixedDeltaTime
smoothedDeltaTime
CinemachineBrain:
UpdateMethod
How can I make the camera moves smoothly with the player, and my parallax works fine?
Answer by Adam_Myhill · Dec 05, 2017 at 01:07 AM
My guess is that your character is moving in a jittery way. Locking the target to the character hides the jitter because the camera effectively jitters along in lockstep with the choppy motion.
Cinemachine damping can expose character translation issues because it smooths the camera movement out which reveals the jitter.
How are you translating the character? Fixed update? Interpolation? Without seeing what's going on that's my best guess. We've had a lot of 'Cinemachine jitters' but in the bast majority of cases it's actually the player that's jittering.
On the Cinemachine Brain, there's a few different update option methods. Try those first as it's easiest and they can often reveal what the real issue is.
I'm moving my character with $$anonymous$$ovePosition as you can see, the other options is what I've already tried. I've tried Fixed Update in the code, and change the CinemachineBrain Update$$anonymous$$ethod, switch Interpolation or Extrapolation and much more. If I double F my player I can clearly see that he is the cause of the jittering. The script is currently like this without the Cinemachine and temporarily my camera is just attached to the player: https://pastebin.com/Y9sj5mYu , I searched a lot, and I'm pretty sure that the problem is with the player's movement, but I've not been able solve the problem. Thanks for the Help!
Answer by LAKSHAYMAVIA · Mar 23, 2019 at 08:09 AM
Changing the interpolation in rigidbody2D component work for me.
Great! Changing the character Rigidbody's Interpolate to Interpolate fixed it.
Answer by sudoman281 · Feb 15, 2018 at 09:50 PM
I was trying to track a physics driven object, so changing Update Method to Fixed Update helped.
The same I have a physics character. Changing to Fixed Update in $$anonymous$$ainCamera Cinemachine Brain helped me. Thanks!