Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Cinemachine camera damping goes choppy after movements stopped

Discussion in 'Cinemachine' started by mushragames, Apr 3, 2024.

  1. mushragames

    mushragames

    Joined:
    Sep 14, 2023
    Posts:
    5
    Hello! The camera is moving well when the character is walking. But when I stop you can see that the camera is trying to adjust the position, and it looks choppy. I've tried many possible fixes: have selected interpolation, tried choosing fixed/late update, and many other things. When damping is 0, there's no such issue. How can I make damping smooth? The video is attached. Thank you in advance!
    upload_2024-4-3_18-51-40.png
    upload_2024-4-3_18-51-22.png
     

    Attached Files:

  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,838
    I suspect that the choppiness is coming from the PixelPerfect Camera component. It's forcing the camera to be on pixel boundaries. When the camera is moving very slowly (for instance as it comes to a stop after damped movement) then its position will be rounded to the nearest pixel, because that is the job of the pixel perfect component.

    Does the choppiness disappear if you remove the pixel perfect component? If so, are there alternate settings for that component that will allow the camera to be on sub-pixel boundaries?
     
    mushragames likes this.
  3. mushragames

    mushragames

    Joined:
    Sep 14, 2023
    Posts:
    5
    Thank you for the reply!

    Does the choppiness disappear if you remove the pixel-perfect component?

    Yes, but now I see how backgrounds are trembling when I move.

    If so, are there alternate settings for that component that will allow the camera to be on sub-pixel boundaries?


    I tried tons of Pixel Perfect Camera settings, but it always behaves badly. I saw in several tutorials people advise using standard 320x180, but for me, 1920x1080 worked fine except for the damping issue mentioned above.

    Okay, I removed the damping effect to check how it works. Now when I build the projects, and when I'm moving, everything around goes blurry except the character. I double-checked that Interpolate is selected in Rb, I'm using FixedUpdate and move character by changing velocity:
    upload_2024-4-10_13-15-20.png

    Can't understand why it's still so blurry
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,838
    The background is trembling because the pixel-perfect pixels (I'll call them the Big pixels) are not falling on the real pixel boundaries (let's call them the Small pixels). The point of the PixelPerfect component is to make sure that the camera is positioned in such a way as to keep the boundaries of the Big pixels aligned with the boundaries of the Small pixels - that way nothing will shimmer.

    So, Big pixels have to be an integral number of Small pixels in size. Once that condition is satisfied, then you should be able to position the camera anywhere on a Small pixel boundary and have a clean image. If your Small pixels are very small compared to the Big pixels, then you will get smoother movement when the camera is going slowly because the rounding only needs to be to the small pixel. So you want that ratio to be large.

    None of this has anything to do with FixedUpdate vs LateUpdate. I suggest that you restore everything to the way it was in your earlier video.

    This blog post might help explain it: https://blog.unity.com/games/2d-pix...-up-your-unity-project-for-retro-8-bits-games
     
    mushragames likes this.
  5. mushragames

    mushragames

    Joined:
    Sep 14, 2023
    Posts:
    5
    Thank you for the reply!
    If I understood you correctly, this ratio is shown below as the Current Pixel Ratio. But all my sprites have 32 PPU, so seems like this value should be correct, but it's 2:1. When I change it to 64, it becomes 1:1. In both cases I don't see trembling, but the image is still blurry on any movements (see attached video).
    upload_2024-4-10_15-59-18.png
     

    Attached Files:

  6. mushragames

    mushragames

    Joined:
    Sep 14, 2023
    Posts:
    5
    Seems like the problem is with my monitor. Looks fine on Mac
    Sorry for bothering you!
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,838
    I'm not a pixel-perfect expert, so I can't really advise you here. In your place, I would investigate how to increase that ratio. Maybe it means altering your sprites to use a bigger PPU. I don't know. You might want to ask on the 2D forum: https://forum.unity.com/forums/2d.53/