Search Unity

Cinemachine object is different across machines

Discussion in 'Cinemachine' started by michalcichra, Nov 26, 2020.

  1. michalcichra

    michalcichra

    Joined:
    Aug 26, 2020
    Posts:
    6
    Hi,

    I'm working on a project with two colleagues and we are using Cinemachine to keep the character in view.

    Cinemachine tries to modify the scene on each of our machines even when nothing changes.
    It changes the with
    m_SensorSize: {x: 1.8085107, y: 1}
    to various different ones like
    m_SensorSize: {x: 1.7777778, y: 1}
    or
    {x: 1.7789757, y: 1}
    . It is a property of the virtual camera object and
    m_Lens
    . We are using text format serialization, because of version control (git). But I can see this will be an issue on any kind of version control.
    Looks like it depends on the machine resolution or something.

    How do people actually work on this? It seems impossible. Every change between our machines is basically a conflict in this file and line.
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi,
    I could not reproduce this on two machines I have. Could you send me your project (or a simplified version), so I can investigate? :D
     
  3. michalcichra

    michalcichra

    Joined:
    Aug 26, 2020
    Posts:
    6
  4. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi,

    I checked the projects on mac and windows, but both machines change
    m_SensorSize: {x: 1.8397436, y: 1} to m_SensorSize: {x: 2.201995, y: 1}
    . After this change, neither machines change the lens parameter. :eek:

    We could do the following experiment to try to narrow down the possible causes:
    - Disable CinemachineBrain (Main Camera -> CinemachineBrain). This way cinemachine is not going to be able to change anything.
    - Check if the problem persists.

    If yes, then I'll investigate deeper into Cinemachine to find the culprit.
    If no, then something else is causing the problem (e.g. HDRP) or perhaps a wrongfully ignored .meta file somewhere.
     
  5. michalcichra

    michalcichra

    Joined:
    Aug 26, 2020
    Posts:
    6
    Hi,

    I tried. Disabling CinemachineBrain in the Main Camera and then forcing saving the scene by disable/enable the main camera produces no changes to the m_SensorSize. Just enabling the Brain will produce m_SensorSize change.
    Pushed it as https://github.com/timewarpinc/submarine/tree/cinemachine-brain-reproduce

    But I have the same issue again in a different project using URP.
    And we are not ignoring any .meta files, so it is not that.
    It changes other fields like `m_LocalRotation` and `m_LocalPosition` by tiny fractions. Looks like rounding errors between platforms.
     
  6. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Hi,
    I started looking into the problem, and I noticed is that the values change differently depending on the Aspect ratio of the Game Window.
    Could it be that you have different Game Window ratios or that it is set to Free Aspect?
     
  7. michalcichra

    michalcichra

    Joined:
    Aug 26, 2020
    Posts:
    6
    Yes, it is set to Free Aspect, because that is the default. And everyone uses different screen, so likely different aspect ratio.
     
  8. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    I could only see difference in SensorSize between commits. It's due to Free Aspect.
    I have not seen difference in `m_LocalRotation` and `m_LocalPosition` though.

    Could you check if the problem persists after setting the aspect ratio to the same thing on both of your machines for 1-2 commits? If yes, I'll dig deeper ;)
     
  9. mxjnordgren

    mxjnordgren

    Joined:
    Jul 30, 2019
    Posts:
    7
    I am experiencing this and it is driving me nuts!
    I have a team of 7 working on the project and we constantly have these changes cluttering our version control.
    I am set to 16:9 but I cannot expect all of my teammates to also use this.
    Is is possible to prevent serializing these properties?
     
  10. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Could you test for a couple of commits to help us find the problem. If everybody sets to the same (16:9), then do you still get clutter in git?
     
  11. mxjnordgren

    mxjnordgren

    Joined:
    Jul 30, 2019
    Posts:
    7
    I just did a quick solo test on my machine. The aspect ratio definitely seems to be the culprit.

    I opened one of the scenes where we often see this issue and made a change (change layer assignment on a GameObject) and saved it with my aspect ratio set to 16:10, which came with some SensorSize and position changes on the virtual camera. I committed that change.

    Then I set the aspect ratio to 16:9 and changed the layer assignment again. I see SensorSize and position changes in Git. Notably, if I just open the scene and change the aspect ratio and save this doesn't happen, likely because that doesn't mark the scene as dirty on its own.
    If I then (without committing that last change) set the GameObject layer back to what it was on the previous commit and save again, that change goes away but the SensorSize and position changes are still present.

    Here's the part you've been waiting for....
    With that change staged waiting to be committed.... if I then change my aspect ratio back to 16:10 as it was in my last commit, and make another GameObject change to trigger the save, Git now shows the only change is the GameObject layer (or none if you changed it back to what's in the repo).

    Some more details:
    The changes are appearing on a virtual camera. I've got a few in the scene so it took me a bit to narrow down which one this is occurring on; It's the one that renders the game view when I'm not in play mode.
    If I play the game and cycle through a few cameras, then presumably any camera that was active at some point changes the SensorSize and position when I save the scene. But without hitting Play, the only one that seems to change is the one showing in the Game window.

    I've asked my team to try it out, but I think this test gave us enough data.
     
    gaborkb likes this.
  12. mxjnordgren

    mxjnordgren

    Joined:
    Jul 30, 2019
    Posts:
    7
    In a nearly empty scene I reproduced the issue.

    1. Create scene and add a Cinemachine camera and an empty GameObject.
    2. Set Aspect ratio to 16:9 in Game window
    3. Commit to Git.
    4. Change aspect ratio to 16:10, make any edit to the GameObject (like position), and save the scene.
    5. Observe in Git that the only pending change is the GameObject.
    6. Add a Cinemachine Virtual Camera. Repeat steps 2 through 4.
    7. Observe in Git that there are now pending changes to the m_SensorSize on the virtual camera.

    So this seems to be occurring only on virtual cameras, and only when you've changed the aspect ratio (or resized the free aspect) from what's in the Git repository, and made any other edits to the scene before saving.
     
    TaraZhongFL and gaborkb like this.
  13. mxjnordgren

    mxjnordgren

    Joined:
    Jul 30, 2019
    Posts:
    7
    In my main scene, I also see a change to m_LocalPosition.x - If I dig into the text further up this looks like it's coming from one of my virtual cameras' Cinemachine Volume Settings custom focus tracking target. This change shows up whenever I see the SensorSize changes.
     
    gaborkb likes this.
  14. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Thank you, we'll look into it.
     
    antoinecharton and mxjnordgren like this.
  15. jduffy_unity

    jduffy_unity

    Joined:
    May 14, 2019
    Posts:
    4
    Was there any progress on this? I'm seeing it as well and its pretty annoying when working in a team. Is there a bug report to watch?
     
  16. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    A fix for this is going to be available in our next releases (2.6.16, 2.8.7, 2.9.0.pre-7).
     
  17. mxjnordgren

    mxjnordgren

    Joined:
    Jul 30, 2019
    Posts:
    7
    Thank you so much!
    I confirmed the fix by following the same test methodology in a project with Cinemachine 2.8.9 and saw no unexpected git changes. This will save my team so much time in resolving merge conflicts.
     
    leohilbert, gaborkb and Gregoryl like this.