Search Unity

Cameras don't switch

Discussion in 'Cinemachine' started by Sybaris, Apr 4, 2021.

  1. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Hi everybody,

    I'm doing around for hours with this now. I have a very simple setup: a main camera with a CineMachine brain on it, two virtual cameras, a timeline with two clips for the two virtual cameras and I would expect that when I run the scene that I get a transiation from the first camera to the second, but the first camera stays active all the time. The brain doesn't switch from camera 1 to camera 2.
    What am I doing wrong?
    Example scene is attached.
    Thanks in advance!
     

    Attached Files:

  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    You need to bind your main camera to the CM track in the timeline:

    upload_2021-4-6_7-29-58.png
     
    Sybaris likes this.
  3. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Thanks for your reply!
    And how would I "bind the camera to the CM track"?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Drag the main camera into the field indicated in the image
     
    Sybaris likes this.
  5. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Yes, that worked!
    My specific problem in the project was, that I am using an asset (HBAO) that creates a second camera below the first one. When I drag the second camera to the CM track then everything is fine.
    Thanks a lot for your help!
     
    Gregoryl likes this.
  6. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Sorry for bothering you again...
    The switching works now. I'm switching from one camera that displays a completely black image to another camera that displays white text on a black background.
    First of all, the second image (which is 1920 x 1080, so it should perfectly fit the screen) is displayed a lot bigger (Pic1) and while transitioning from the black image to the black image with white text, the content of the main camera is shining through (Pic2).
    Any idea what could be the cause for this behaviour?

    Problem1.png Problem2.png
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Are you using CM Storyboard?
     
  8. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
  9. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    That's the original image displayed by the second camera btw.:

    Screen1.png
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Can you show the inspector for the storyboard of the image that is displaying the wrong size?

    For the bleed-through image: that is a known issue, and unfortunately the only way around that is to black out the main camera by having it look at something black.
     
  11. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Here Problem3.png you are:
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    What version of CM are you using?
     
  13. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    2.7.3
    Unity 2019.4.23f
     
  14. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    I found the problem: it was again the second camera that is created from the asset. It's not HBAO, it's an antialiasing asset that creates a second camera, renders the image in a much higher resolution - hence the distortion - and samples it down for the first camera. Removing the asset and the second camera fixes the problem.
    Thanks again for your help and sorry for the hazzle!
     
  15. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Well, now the switching from one camera to the other and back again works, although I have to also animate the priorities of the virtual cameras to get what I want (shouldn't be placing the clips on the CM track be enough to decide which clip is playing when the cameras have the same priorities?)

    But now when I record the track with the Unity recorder the storyboard clips don't show up at all - it only shows the main camera.
    Is it possible to record the track "as is"?
     
  16. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    OK, I found out that I have to use a recording track in the timeline.
    When I select "active camera" it records only the main camera - like the normal Unity recorder - no storyboards.
    When I select "main camera" it records a black screen - although in the game window it shows the correct clips.
    When I select "game view" it does not record full screen 16:9, 1920 x 1080.
    So what am I supposed to select to get a simple 1920 x 1080 video?

    Just to make sure: there is no other camera active. Shouldn't "active camera" and "main camera" be the same when there's only one camera?
     
  17. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    I have created a unity package with a very simple setup - actually more or less the same setup as the first one in this thread. And I have recorded two clips via a recorder track - the first one with "active camera", the second one with "main camera". Both only seem to record the main camera, no storyboards.

    btw: if I have a timeline locked and open another scene, the timeline still shows the old timeline...
    And even worse: it still seems to have the old camera set as "track camera"!! When I hit record, it records the main camera from the closed scene...
    Another minor issue: changes in the timeline are not reflected as "changed" - there is no asterisk after name in the title bar as usual when something has changed; although when closing the scene, one is being asked whether the scene shall be saved or not, so the changes are obviously recognized.
    EDIT: I have to correct myself: changes in timeline - for example moving a clip - are NOT recognized as changes. Opening another scene does not ask for saving and changes are lost!

    Another issue: at the end of my second transition the rotation of the camera instantly jumps to 380/-148/0. There is no key frame on any of the tracks and even if I mute all tracks this rotation takes place. I even created a new EMPTY cinemachine track - without a clip, muted the old cinemachine track, and this rotation takes place on the first frame.
    Any idea where this rotation comes from or any suggestion how to find out where it comes from?
     

    Attached Files:

    Last edited: Apr 7, 2021
  18. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    OK, to make things easier to fix, I put the whole main scene in a package.
    You can download it via this OneDrive link:
    https://1drv.ms/u/s!AvTX5a0Y41ck5u8h04eGLzMBlV92_w?e=946IYD

    Below the folder "CineMachine" you'll find a timeline. If you select that you'll see a camera track at the top. If you move to 10:00 you'll see that the camera instantly rotates to 380.043/-148.317/0. And you'll also see that there are no keyframes at that frame.
    So where does this rotation come from?
     
  19. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Another annoyance: When you play a timeline to a certain point and then return to 0, the animated values seem to not reset to their original values but stay the way they were when the animation was stopped. At least when there is no dolly track at the beginning. That is VERY confusing (especially for beginners, because it takes quite a while to figure out why everything gets messed up - mainly the camera) and it's a lot of work to reset everything to their initial values again. That means that all animated values have to have key frames at the beginning of the animation.
    Other animation systems that I know (WPF for example) treat the initial values as "implicit key frames", that means that when you return to the beginning of the animation everything is reset to their initial values automatically.
     
    Last edited: Apr 8, 2021
  20. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Thanks for uploading the project. I had to dig into it a little, but it turns out that there is a bug in the TrackedDolly behaviour when there is no Aim component and the Camera Up mode is Default. That's where the weird rotation is coming from. Thanks for bringing this up, we will fix it right away.

    For now, a simple workaround is to put DoNothing in the vcam's Body section, and add a CinemachineDollyCart behaviour to the vcam, set the path there, and animate that component's position, like this:

    upload_2021-4-8_7-42-26.png

    That will make the vcam travel along the path.

    Let me address some of the other issues you mention.

    If you have a Cinemachine track with an active CM clip on it, that completely overrides the priority system. You should not have to animate the priorities, ever, so long as there is always an active CM clip on the track. If you leave a "hole" as you do in the project you posted, then the priority system becomes relevant within that hole. It's best to always have a clip, so that timeline has full control of the camera, making the priority system irrelevant.

    This is the "hole", where there is no CM clip, and the priority system takes over:

    upload_2021-4-8_7-25-37.png

    Recorder: I am not a recorder expert, so can't really advise about that. Perhaps someone else on this forum knows and can answer. It seems to me that to include the canvases you have to record the game view. I don't know why the resolution is wrong, but surely there is a way to get it right or it's effectively useless. Is it possible that your game view needs to be the correct size on your display when recording?

    Perhaps you can ask on the recorder forum: https://forum.unity.com/forums/audio-video.74/

    Timeline: You bring up several issues, and I suggest that you post them on the Timeline forum. Here we focus on Cinemachine-specific things. Timeline forum is here: https://forum.unity.com/forums/timeline.127/
     
    Sybaris likes this.
  21. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Another thing I forgot to mention.

    You are animating the main camera's transform in your timeline. You really should avoid doing that, as the CM Brain wants to control the camera and will fight with the animator. Perhaps that's where some of the confusion about initial positions is coming from.

    If the purpose is to point the camera at a black thing during the storyboard sections, then I would suggest an alternative approach: create a black child object on the main camera, positioned directly in front of the camera. When you need it to be present, use an activation track in the timeline to turn it on. That way you never have to touch the camera's transform.
     
    Sybaris likes this.
  22. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Hi Gregoryl,

    thanks a lot for the detailled response!
    I'll try what you suggested and give you feedback.
     
    Gregoryl likes this.
  23. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    I fixed the recording issue in the meanwhile. It's as if one can only record from the game view. Another issue was that although I wanted to display a 1920 x 1080 image in a 1920 x 1080 game view I got bars on the top and bottom where the background was shining through. I had "best fit" for the image, but I had to choose "stretch to fit" - for what reason ever...
     
  24. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    I already asked this in another thread in the timeline forum, but it's probably better to ask this here.
    I played around with "Speed" in the dolly cart but whatever I enter, nothing changes.
    How am I supposed to use this?
     
  25. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Speed will work only in Play mode. In timeline, you're meant to just animate the position directly (same as you did for the DollyTrack vcam).
     
    Sybaris likes this.
  26. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Thanks again! ;-)
     
    Gregoryl likes this.
  27. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    @Gregoryl
    Hi Gregory,

    I moved the "camera doesn't rotate" issue to the timeline forum and now they sent me back here: Several timeline issues - Unity Forum
    Is it true, that it is not possible to rotate the camera when it is moving on a dolly track??
    In the video that I have in mind, I would like to look in other directions than the one the dolly is facing at... :-(
    And I'm pretty sure that I already had something like that... I was rotating the camera in some other direction than the one given by the path. Is it maybe a "feature" of the dolly cart only?

    EDIT: Since I cannot use the "normal" dolly track because of the "rotation bug" I'm somewhat stuck now...
    Wouldn't it be possible to make it an option whether the dolly should take over rotation? Shouldn't be too much work - just a property and another if...

    Another EDIT: You posted an explanation for the "rotation bug"; I was working with the normal dolly for a quite a while without problems. So what exactly was producing the problem? Maybe I can avoid doing such things and continue working with the normal dolly track?
     
    Last edited: Apr 12, 2021
  28. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    5,154
    Sorry, I misled you earlier. It's true that the DollyCart controls its own position and rotation, so you can't animate the rotation separately. Happily, there is an easy solution.

    Instead of adding a CinemachineVirtualCamera behaviour directly to the dolly cart, you should have a DollyCart GameObject with only the DollyCart behaviour, and then create a new VirtualCamera GameObject as a child of the DollyCart. Put "No Nothing" in the vcam's Aim and Body. That way, the vcam will be a "passenger" in the cart, and you can animate its position and rotation relative to the cart.

    Does that make sense?
     
    gaborkb and Sybaris like this.
  29. Sybaris

    Sybaris

    Joined:
    Aug 19, 2013
    Posts:
    81
    Yes, that makes sense. Sounds good. :)
    Thanks again!
     
unityunity