Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

cinemachine freelook prefabs seem to become corrupted

Discussion in 'Cinemachine' started by mradfo21, May 24, 2018.

  1. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    Cinemachine freelook cameras seem to have alot of trouble keeping their settings when saved as prefabs. I cant exactly figure out what corrupts their data. But the Top Rig, Middle Rig, Bottom Rig settings seem to get corrupted and reset every now and then. I can tell when this happens too as the arrow next to them disappears

    upload_2018-5-24_11-37-31.png

    when I select one of the corrupted rigs
    upload_2018-5-24_11-38-1.png

    i see this appear in the object heirarchy

    upload_2018-5-24_11-38-19.png


    the ONLY way to keep them for sure is to save via unity collaborate and constantly revert them after working in the project ... man.. what a nightmare
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    oh really ?!
    what version of Unity?
     
  3. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    2018.1.0f1
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    trying to repro... can't seem to do it. Any thoughts on what kind of things you're doing in the editor that might make it happen?
     
  5. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    hehe its slowly corrupting them more and more

    upload_2018-5-24_13-32-54.png

    so i'm not sure. I do have some editor scripts that are running update methods and I do have an

    [InitializeOnLoad]

    that automagically spawns some gameobjects and prefabs into the scenes (but not the cameras).

    I'm not sure but i'll keep testing and see if i can find a pattern
     
  6. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    luckily collaborate's revert is saving me
    upload_2018-5-24_13-36-0.png
     
  7. Feriluce

    Feriluce

    Joined:
    Nov 28, 2013
    Posts:
    5
    I have a very similar, if not the same, problem. I have created a prefab with cinemachinefreelook on it, and it seems that whenever I try to change settings on that prefab, it spawns those 3 rigs in the scene, tries to parent them to the prefab, which fails, and then throws this nullreferenceException.

    Error.png
     
  8. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    hurrah! im not crazy!
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    I really can't repro this!
    Can you tell me which version of Unity, which version of CM, and what exactly are the steps to reproduce?
    I've tried changing all sorts of settings but it refuses to misbehave.
     
  10. Feriluce

    Feriluce

    Joined:
    Nov 28, 2013
    Posts:
    5
    I'm using unity 2018.1.0 and Cinemachine 2.1.13, but I just tried to reproduce it myself, and now it doesn't happen for me either.
    It seems like the problem was in creating the prefab though. When I tried creating new prefabs this time, the 3 child rigs were created underneath the prefab. That didn't happen with the prefab that was broken. That one was just a single object, which I assume is why it kept trying to create the missing rigs.
     
  11. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    Ok here's how I think you repro this. Make a cinemachine prefab out of a free look. Instantiate it at runtime. Make changes to it. Drag that to make a new prefab on disc. Then drag the camera ontop of the original prefab to replace its settings.

    Now you'll start to see TopRig, MiddleRig, and BottomRig appear in the heirarchy of the game. This means your F***ED. Cinemachine is now destroying your cameras.

    Restart Unity and you'll be greeted with this:

    upload_2018-6-22_17-7-1.png

    Not having the arrows next to your camera is BAD NEWS.

    When you run the game cinemachine will make have erased all your rig settings and there's no way to get them back outside of version control.


    Now this could ALLLLL be avoided if you could actually copy the rig settings during runtime and paste them onto the prefab on disc like every other object in unity. I know you'd mentioned this was working but it does not sadly.
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    Not sure exactly what you mean by that last step.
    After making the second prefab, if I drop my FreeLook from the hierarchy onto the prefab, all is fine, the settings get copied. If I try to drag the second prefab onto the first prefab, I get this:

    upload_2018-6-24_8-13-13.png

    If I click Yes, then click on the profab, then the Top, Middle, and Bottom rigs from the prefab get moved to the hierarchy, and the prefab is broken.

    Is that consistent with what you're seeing?


    If I do this on the FreeLook in the hierarchy:
    upload_2018-6-24_8-27-47.png

    Then this on the FreeLook in the prefab:
    upload_2018-6-24_8-28-32.png

    Then it works perfectly.
    How are you doing it differently?
     
  13. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    Yes! Yhat's exactly what I'm seeing.

    So on my machine using two different versions of cinemachine - the package manager one, AND a beta I was sent of a newer (sexier) version, the Paste Component Values only copies values into that top section, not to any of the rigs. Basically the gear produces this result:
    https://forum.unity.com/threads/copying-properties-from-play-mode-onto-prefabs.532085/

    I'm really sorry this has been so hard to track down. Do you think the behavior repro-'d above is fixable?
     
  14. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    heres when you know its bad

    upload_2018-6-25_22-42-34.png
     

    Attached Files:

  15. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    notice there are no rigs now in the prefab:

    upload_2018-6-25_22-44-47.png
     
  16. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    @mradfo21 Thanks for your persistence and patience!
    I was able to identify and fix a bug that was causing Paste Component Values to only paste the top section of the FreeLook. That fix will be in the next CM update.

    For the orphaned rigs in the scene view, I don't know how you're getting them unless you dragging and dropping a FreeLook onto a prefab FreeLook. In that case, Unity displays this warning dialog:

    upload_2018-6-26_15-56-7.png

    My advice to you: Don't do it. Just say no.

    The correct way to modify a prefab FreeLook is to paste the values onto an instance, then apply that instance back to the prefab.

    upload_2018-6-26_15-58-33.png

    If you do it like that, you won't get any orphan rigs.
     
  17. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    Yeah I've been replacing just to get around the copy paste issue. So it sounds like with the next update this wont even be an issue! I'm super happy you could see that on your end. Cant wait for the new Update! Any ETA on that?

    Great work Gregoryl !
     
  18. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    New update should be available in Preview within the next few days, I'll let you know when it's there.
     
  19. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    This is still suuuuper painful. Any chance this update is coming soon?
     
  20. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    Yes, there is a new CM version (2.2.6) in Preview, which is waiting for a final QA pass before it can be released officially. You can grab it from there if you really need it.
     
  21. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    Any news on this? It's still destroying my work constantly... would LOVE a fix
     
  22. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    The current version of CM (2.2.7) will not create orphan rigs, provided that you follow the recommended workflow when working with prefabs: drag them into your scene, work on then there, hit Apply, then delete them from the scene.

    I'm not sure what you're doing to get the corruption.
     
  23. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    Yeah I really wish you could use the gear icon to copy settings between Cinemachine free look cameras but again it never fills in any of the composer values. It'll only take from the top with field of view etc.

    I'm using 2.2.7

    When the corruption occurs on the camera prefabs it always throws an error about "repainting" something. I feel really bad because I know you've been working on this and I keep hearing about this being patched but It really continues to happen. I no longer drag a prefab from the hierarchy to copy the settings (despite that being the only method that works) because I do get why that would cause the corruption. I'm currently working on abstracting cinemachine free look settings into a scriptable object per camera because it's the only way to tweak the values while the game is running (since my cameras are instantiated).

    I guess this is the end of the road if its officially been "fixed". You've definitely done a lot putting up with my complaints and maybe someone out there will get these new fixes and it'll work perfectly. Perhaps since i corrupted things they are broken permanently now *shrug. Hopefully the game gets to a place soon where I could package it up and send it to you so you could see the repro case. I just feel like your never gonna want to inherit my 30k codebase to try and solve a single bug.

    either way I'm just going to put as many of the CM settings into scriptable objects ... that seems to be my only hope.

    one thing I cant figure out how to access via script is the aim offset values for the orbits


    this is how i adjust the radius and the screen X, Y. I'm just not sure the syntax to adjust the aim offset on the 3 different rigs ?


    Code (CSharp):
    1.             CinemachineFreeLook cam = camera.gameObject.GetComponent<CinemachineFreeLook>();          
    2.  
    3.             for (int i =0; i < 3; i++){
    4.                     CinemachineComposer composer = camera.GetComponent<CinemachineFreeLook>().GetRig(i).GetCinemachineComponent<CinemachineComposer>() as CinemachineComposer;
    5.                     if ( cameraStateAsset.followTeamCenter == true){
    6.                         cam.m_Orbits[i].m_Radius = Mathf.Clamp(characterController.team.teamRadius * cameraStateAsset.teamRadiusBias, cameraStateAsset.teamRadiusMin, cameraStateAsset.teamRadiusMax);
    7.                     }
    8.  
    9.                     if ( cameraStateAsset.radiusControlsYoffset == true){
    10.                         float yoffset = Map(cameraStateAsset.yoffsetMin, cameraStateAsset.yoffsetMax, cameraStateAsset.fovDistanceMin,cameraStateAsset.fovDistanceMax, characterController.team.teamRadius);
    11.                         composer.m_ScreenY = yoffset;
    12.                         composer.m_ScreenX = cameraStateAsset.xoffset;
    13.                     }
    14.             }
     
  24. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,733
    I'm really sorry to hear that you're still having trouble with this. If you're willing to put together a sample project with reliable repro steps, I'd be happy to have a look at it.

    For the aim offset, you want composer.m_TrackedObjectOffset.

    If you're willing to play around with experimental stuff, there is a new simplified FreeLook availabe in CM 2.2.8 (in preview). It takes a different approach from the old FreeLook, and doesn't use the hidden object children, which is the source of your prefab woes. To access it, you'll need CM 2.2.8, and you'll have to define CINEMACHINE_EXPERIMENTAL_VCAM in your player settings. Then, add the CinemachineNewFreeLook to an empty game object.

    The setup is a little different: you access Aim, Body, and Noise CM components directly as components on the game object. The settings apply to all three rigs by default. You then create customizations for the top rig and bottom rig, if you want them to be different from the main (middle) rig.

    upload_2018-11-2_15-37-6.png
     
  25. mradfo21

    mradfo21

    Joined:
    May 16, 2013
    Posts:
    186
    That's phenomenal! I'd been hoping things would go that way because often I really do keep most of the settings the same.

    I'm not too keen yet on using experimental features as i'm trying to keep things stable but Its just super cool to know that's coming.

    Thanks for the m_TrackedObjectOffset callout. Gonna put that in now!