Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

CineMachine tracked Dolly problem

Discussion in 'Cinemachine' started by ControlledDrive, Feb 9, 2021.

  1. ControlledDrive

    ControlledDrive

    Joined:
    Mar 28, 2020
    Posts:
    10
    Hello, I have a problem with Cinemachine, with the "tracked Dolly" function, I did all the camera path with the script "CinemachinePath" and it works fine, but however when I move my character it starts to shake and I don't know how to fix this effect. Before when I used a camera without tracked Dolly, it didn't give problems, and it was solved with the following script:

    Code (CSharp):
    1. using Cinemachine;
    2. using UnityEngine;
    3. using UnityEngine.U2D;
    4. using System.Reflection;
    5.  
    6. /// <summary>
    7. /// Add this component to a camera that has PixelPerfectCamera and CinemachineBrain
    8. /// components to prevent the active CinemachineVirtualCamera from overwriting the
    9. /// correct orthographic size as calculated by the PixelPerfectCamera.
    10. /// </summary>
    11. [RequireComponent(typeof(PixelPerfectCamera), typeof(CinemachineBrain))]
    12. class OrthographicOverride : MonoBehaviour
    13. {
    14.     CinemachineBrain CB;
    15.     object Internal; // PixelPerfectCameraInternal
    16.     FieldInfo OrthoInfo;
    17.  
    18.     void Start()
    19.     {
    20.         CB = GetComponent<CinemachineBrain>();
    21.         Internal = typeof(PixelPerfectCamera).GetField("m_Internal", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(GetComponent<PixelPerfectCamera>());
    22.         OrthoInfo = Internal.GetType().GetField("orthoSize", BindingFlags.NonPublic | BindingFlags.Instance);
    23.     }
    24.  
    25.     void LateUpdate()
    26.     {
    27.         var cam = CB.ActiveVirtualCamera as CinemachineVirtualCamera;
    28.         if (cam)
    29.             cam.m_Lens.OrthographicSize = (float)OrthoInfo.GetValue(Internal);
    30.     }
    31. }
    32.  

    However, now this script doesn't fix the problem, I don't know if it has any relation with the "pixel perfect". If someone knows how to solve the character's shaking, it would help me a lot. Anyway, here you have a video, with the shaking of the character:


    In the case that you can't notice the problem, it is similar, but at a lower level, to what happens in this video in the second 0:13:

    (I don't know how to apply that solution, although I don't think it will work, since it doesn't use cinemachine).

    And here is how I have my main camera and my virtual camera configured:

     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hello,
    Did you add CinemachinePixelPerfect extension to your vcams? You need to add PixelPerfect to the Main Camera and CinemachinePixelPerfect to your vcams.

    If no, then add it.
    Then you won't need the OrthographicOverride script.
     
    Last edited: Feb 9, 2021
  3. ControlledDrive

    ControlledDrive

    Joined:
    Mar 28, 2020
    Posts:
    10
    Hello, Now I have the "CineMachine pixel perfect" component in my virtual camera, however, it did not solve the problem.
    If you are wondering, now I have the "common pixel perfect" in my main camera and in the virtual one I have the extension "cinemachinePixelPerfect" as I show in this image:
     
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you show the packages you have installed in your project?
     
    ControlledDrive likes this.
  5. ControlledDrive

    ControlledDrive

    Joined:
    Mar 28, 2020
    Posts:
    10
    Sorry for the late reply, well, these are the packages I have in the project:
     
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    You have Universal RP (URP) and 2D Pixel Perfect packages in your project. Remove 2D Pixel Perfect package from your project, because URP has a built-in Pixel Perfect component. Then add URP's Pixel Perfect to your Main Camera. Then make sure your vcams have the CinemachinePixelPerfect extension.
     
    Gregoryl and ControlledDrive like this.
  7. ControlledDrive

    ControlledDrive

    Joined:
    Mar 28, 2020
    Posts:
    10
    "Hm, I removed the pixel perfect 2D and did all the corresponding configuration to make the Universal RP work, I added the component "Pixel Perfect 2D experimental" in my main camera and still the same problem, was that the component that I had to add or was it another one? Here is a picture of what I added to my main camera:



    (by the way, I have the CinemachinePixelPerfect component on all my virtual cameras, since I only have one)
     
    gaborkb likes this.
  8. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Looks good :)

    Good :)


    How do you move your player (blue box)? Could you show the script and the player's components?

    What update method is used when your vcam is Live when playing the game (see the attached image showing what I am looking for)?
     

    Attached Files:

    ControlledDrive likes this.
  9. ControlledDrive

    ControlledDrive

    Joined:
    Mar 28, 2020
    Posts:
    10

    Apparently from what I've been able to discover the cause of this is the pixel perfect in my case.

    I even removed the Cinemachine and started using a more normal type of camera and nothing, it's the Pixel Perfect.