Search Unity

Question Cinemachine problem: no body, aim & noise properties showed in inspector :(

Discussion in 'Cinemachine' started by karlosey, Dec 6, 2022.

  1. karlosey

    karlosey

    Joined:
    Dec 6, 2022
    Posts:
    4
    I've checked a few posts on similar problem and done the re-imported, but the problem still exists. There is no error reported btw.
    However, this situation only exists in a half-done project which I'm working on. The functions work perfectly fine on new created projects.
     

    Attached Files:

  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Two questions:
    1. Are there any errors or messages in the console?
    2. Are prefabs involved?
    3. What version of Cinemachine are you using?
    ok fine, it's three questions.
     
  3. karlosey

    karlosey

    Joined:
    Dec 6, 2022
    Posts:
    4
    1. There are no errors in the console.
    2. Yes there are prefabs invovled.
    3. Current version of my Cinemachine is 2.8.9

    Thx for replying so quickly!
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Do you get this problem when looking at the prefabs themselves, or when looking at the prefab instances?
     
  5. karlosey

    karlosey

    Joined:
    Dec 6, 2022
    Posts:
    4
    It occured both ways. I tried create CM vcam under both scene and prefabs, either of them contains body, aim or noise in inspector.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    With the newer versions of Cinemachine, it's not possible to add the CinemachineVirtualCamera or CinemachineFreeLook component to a prefab instance. You have to add these components to the prefab asset itself - not to the prefab instance. You can modify the settings in the instance, but not add or remove the component. This is due to a limitation in the way these components are implemented. If it worked in older versions of CM, it was only by accident and it's not reliable. Note that this problem is fixed in CM 3.0, but that is not yet released.

    Are you able to convert these objects to follow this pattern?
     
  7. karlosey

    karlosey

    Joined:
    Dec 6, 2022
    Posts:
    4
    Thx I understand the logic now, but this problem still exists even there is no prefabs invovled. I created a CM vcam in an empty scene and still the problem occured, and there is no error reported in console.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    That's not possible. Can you show the inspector?
     
  9. emirsoylu03

    emirsoylu03

    Joined:
    Jul 14, 2019
    Posts:
    3
    Did somebody solve this problem? It still continues for somebody. The unity version is 2021.3.15f1 and the Cinemachine version is 2.8.9. re-importing package isn't work

     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Did you try closing Unity, deleting the Library folder, then re-opening the project?
     
  11. Re-Ch

    Re-Ch

    Joined:
    Mar 11, 2023
    Posts:
    1
    I also encountered the same problem. After upgrading the old version of the unity editor project to the new version, the body, aim and other attributes disappear. The current unity version is 2021.3.8f1c1 and the cinemachine version is 2.8.9. upload_2023-3-11_23-17-50.png
     
    Last edited: Mar 11, 2023
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    It looks as though something in your project cache is corrupted. The CM custom editors are not appearing. Try closing Unity, deleting the project's Library folder, then re-opening the project.
     
  13. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    Hi @Gregoryl

    Indeed on Cinemachine 2.8.9 when looking at prefabs in the project there are no aim/body. They do appear when we open the prefab in Prefab Mode. I believe the component are correctly instantiated at runtime as well.

    The only issue that appeared for me recently is that aim component is non functional at runtime, follow target is specified but changing the parameters does absolutelly nothing and the camera is not aiming. I'm not sure on how to troubleshoot. If I create a vcam manually at runtime and specify the same components/targets it works as expected.

    Pic1 : Composer not appearing (but instancing at runtime and in prefab scene)
    upload_2023-4-7_16-39-50.png

    Pic2 : The Follow target is not followed neither in composer nor in any Aim component set at runtime. Here you clearly see the target to which the offset applies on the yellow debug point but the camera does not aim at all (here on the example you can see for instance the soft zone. Target should be inside)

    upload_2023-4-7_16-53-46.png

    If it is related to prefab I might need to give cm 3 a go as the prefab workflow is pretty important for us. I'm just a little bit afraid of the update cost atm as I'd like to avoid any heavy refactoring (and I guess v2 and v3 can't work together ?)
     

    Attached Files:

  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    For Aim components, you need to set the LookAt target. What happens when you set it?
     
  15. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    Both LookAt and Follow are specified, sorry for the missing info. I mixed up both names. I'm still at it, I'm not sure what to look for in a debug session.

    I'm trying to find a way to force a sort of Start/Awake of the camera after setting all the object refs at runtime, my theory is that maybe because it is on the topmost prefab gameobject it might temper something during the init phase of the vcam ?

    I'll let you know for the debugging, atm my entry point is in the Vcam code
    Code (CSharp):
    1.  override public void InternalUpdateCameraState(Vector3 worldUp, float deltaTime)
    2. ...
    3.                     transform.rotation = State.RawOrientation;
    Which always set in an Identity Quaternion, for position the framing transposer seems to works.
     
    Last edited: Apr 12, 2023
  16. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    Okay, so, looks like there is indeed something going on. It's a behaviour that sometimes happen to me with other extension creating child game objects in editor while in prefabs (like TMP), it sometimes duplicates the generated items and could end up having issues, like here now in v2.

    I have a duplicate transposer and the debugger never hits the update of the composer for this camera.

    upload_2023-4-12_19-9-17.png

    I might be able to hack in through retrieving the CinemachineComponentBase and issuing a new one with fixed components.
     
    Last edited: Apr 12, 2023
  17. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    It is alive ! Well it works with this hack. Should any duplicate component be needed it won't anymore, but I believe nothing as such exists ?
    Code (CSharp):
    1.         private void FixCMComponents()
    2.         {
    3.             var vcam = ((CinemachineVirtualCamera)VirtualCamera);
    4.             var pipe = vcam.GetComponentPipeline();
    5.             var comps = pipe.DistinctBy(p => p.GetType()); //moreLinq api. replace if needed.
    6.             if (comps.Count() != pipe.Length)
    7.             {
    8.                 Debug.Log($"[FixCMComponents()]There are dups in CM pipe, will try to fix", gameObject);
    9.                 var toRemove = pipe.Except(comps).ToList();
    10.                 Debug.Log($"[FixCMComponents()]Will destroy {toRemove.ToDelimitedString(";")}");
    11.  
    12.                 foreach (var cinemachineComponentBase in toRemove)
    13.                 {
    14.                     Destroy(cinemachineComponentBase);
    15.                 }
    16.  
    17.                 //Tell cm to update the components
    18.                 vcam.InvalidateComponentPipeline(); //Well it's not and Editor only API anymore I guess. Good it's public.
    19.  
    20.             }
    21.         }
     
  18. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    189
    Heyyoo :)

    Glad you found a way around. We are checking to see if this could be prevented from happening.
     
    Whatever560 likes this.
  19. kaiware007

    kaiware007

    Joined:
    Sep 4, 2014
    Posts:
    1
    I don't know if this will be helpful,
    If the project path contains certain Japanese characters,
    I have reproduced the phenomenon that the body of CinemachineVirtualCamera is not displayed.
    In that case, Unity crashes while installing Cinemachine in PackageManager. upload_2023-4-14_22-52-27.png upload_2023-4-14_22-52-11.png
     
  20. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    189
    Nice! Can you share the project? And what steps you did to create it? Looks like your hub is not in English did you change the language?
    Are you sure this is japanese? Can you give me the characters used?
     
    Last edited: Apr 14, 2023
  21. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    the sole drawback is that there is a Null Exception raising for one frame regarding the fact that we invalidate the pipe (that just sets null internaly) but it recovers on the next frame.
     
  22. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    189
    @Whatever560 @kaiware007 @karlosey @emirsoylu03
    Do you happen to have the bug consistently? How does it happen? We would like to find why it is happening and fix it. We are struggling to get a repro on our side. If you happen to have consistant repro steps it would be very helpful.

    Let us know :) .
     
  23. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    So this is my repro with 2021.3.19f1 LTS and latest cinemachine. I use this workflow a lot as it allows for direct access to "scriptable" like prefabs which can be easilly tuned at runtime without having to open the prefab scene.

    1. Create a GO with a VCam
    2. Drag the GO to create a prefab out of it
    3. Edit the Aim / Body from the project view.

    Issue A : When selecting the prefab in project view aim and body are set to none (As pic 1 above) or are inconsistent with the prefab scene (once you double click on it from the project view). I just tried to repro it once again and the behaviour is still inconsistent, but it's not the same result as above pic1 (which had both missing).

    Issue B : When I instantiate this prefab at runtime I end up with the same inconsistent components (In the example above I had duplicates that prevented things to work)

    Note : If I drag to create a prefab out of a Vcam that already has its aim and body set then it has a correct Aim and Body but if I edit the Aim / Body components again from the project view then the inconsistency comes again.

    Note2 : Inconsistency means missing aim and or body in either project view or prefab scene, or duplicate at runtime.

    Opinion : In my understanding those issues make sens, as I'm not sure prefabs supports having hidden components /GOs added to their hierarchies when not in the prefab scene. And it's quite a narrow (yet my own ...) usecase.

    Hope it's helpfull.
     
    antoinecharton likes this.
  24. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    189
    We removed hidden components in CM3 but we can't change it on CM2. We will discuss the problem see if we can at least improve the current workflow in CM2 but our options might be limited.
    Thanks a lot for all the feedback :)
     
    Whatever560 likes this.
  25. Whatever560

    Whatever560

    Joined:
    Jan 5, 2016
    Posts:
    513
    Yeah I'm aware of it for CM3, I believe it's a good take indeed. You're welcome, it might only be an internal change on how the hidden CM GO and its component are discovered (hopefully it shouldn't bring regressions). Anyway as the hack work it's not high on my list.

    The only thing that is really broken in the workflow is that I'd like to be able to consistently edit the vcam prefabs directly in the project view inspector without having to open them.

    Note : A thing I observed, If no CM GO was added while creating the prefab (aim/body empty on a brand new vcam component) and then I add a body/aim in the project view inspector, I can see the prefab update bar, that in my understanding means it is adding the cm gameobject to the prefab. So the bug really is on how this cm go and the vcam component interact on a root prefab in the project view and when instantiating.
     
    antoinecharton likes this.