Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Created VC on Prefab player instance, no brain created

Discussion in 'Cinemachine' started by ferverence, Jul 31, 2020.

  1. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    16
    I created a VM on a player prefab which is meant to be spawned for network play. After creation there is no Brain. And after I create the brain, it seems they aren't connected. There is also no CM's nor Brain in my project (outside of prefabs). Not sure what to do here.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,953
    For the vcam to work, you need a CM BRain on the main camera and that camera must have the vcam's layer enabled in its culling mask. The brain will not get created automatically, you must ensure that it is added.
     
  3. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    16
    Thanks for taking the time to respond.

    There must be a config issue on my part. My setup is as follows:

    Scene > Unity Camera > Brain Attached
    Networked Prefab (Runtime Spawn) > Child Unity Camera (tagged MainCamera) > Child VCAM of tagged MainCamera.

    With this setup, the camera is beautiful, however runtime changes to the VCAM are not represented in game (But they are seen within scene view (i.e. Dutch FOV, xy offsets, blending with priority, etc...)..
    If I make the layer changes you mention, it's as if at runtime only the MainCamera is being used.

    I've set up a fresh project and can manage VCAM's great. But once I add a networked prefab with a VCAM I continue to have this issue.

    I can post screenshots of the configs later today if you have time to check it out. Maybe it's something that can also help someone else as well. thanks again.

    edit: Additionally I assumed that one of my scripts might be affecting it, but the only thing that touches the camera is my FirstPersonController which I believe shouldn't override the VCAM like this seems to be doing.
     
    Last edited: Aug 4, 2020 at 7:11 PM
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,953
    The paradigm is that there should be only one Unity Camera, the one with the brain on it. All the vcams will drive that camera while they are active. Can you try to remove the Unity Camera component in your prefab? You should remove that component, and use the AddComponent menu to add a CinemachineVirtualCamera component in its place (get rid of the child vcam).
     
  5. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    16
    Thanks so much - got it! Very cool :)
     
  6. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    16
    Sorry to reach back out - But it actually wasn't working as intended. When I do everything you mentioned, I lose some control over the MainCamera and it doesn't react the same way. I lose the Y axis and all VCAM attributes in game. Here is a screenshot of how I have it set up where it is working as I'd like. However I know this isn't good design (Even when you open the prefab the vcam and camera sometimes start spinning out of control - But it consistently works great in game although I want to clean it up as it's bad vcam design.




    Here is a video of the behavior this creates in game:




    I just can't seem to mirror that in a better design without breaking it completely.


    edit: Ok wow now my only issue is that the VCAM cannot look along the yaxis when applying the design you mentioned. Writing this out helped :p Hopefully I can figure that part out and it will be clean going forward!
     
    Last edited: Aug 7, 2020 at 6:08 AM
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    3,953
    Your main design problem is making the vcams children of the main camera. Don't do that. Main camera with brain should be one game object by itself, and vcams should be independent game objects. Otherwise you will lose control and get dog-chasing-tail effects.
     
    ferverence likes this.
  8. ferverence

    ferverence

    Joined:
    Jul 15, 2014
    Posts:
    16
    Great thanks. Good times ^-^
     
unityunity