Search Unity

Keep target always in frame while blending?

Discussion in 'Cinemachine' started by MSachs, Mar 6, 2018.

  1. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    Hi,

    is there a way to always keep the target of a free look camera in the center of the screen while blending to itfrom an other freelook camera?
    I basically have a big object with a free look camera attached to it and want to blend to a smaller detail of the object with a separate freelook camera attached. While blending I would like to have the detail always at or near the center of the screen. Right now it often happens (depending on the position in space of the two cameras to each other) that the target completely leaves the frame and gets pulled back into frame just before the blending is completed.

    I tried setting all damping to 0 but that has almost no effect.

    Hope there is a way to do that :)

    thanks in advance
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Normally, if the LookAt targets are the same on both FreeLooks, there would be no reason for the camera to look elsewhere during the blend. Could you upload a little video showing the problem?
     
  3. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    They don't have the same LookAt targets. The first camera has the center of the "big object" as its target and the second camera has the center of the "detail object"...

    What I want is basically to start blending and as soon as possible lock onto the target of the freelook which gets blended to so it is in frame and then completely blend the camera to its final position... Hope that makes sense.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    In that case, what will happen internally during the blend is that the LookAt location will be lerped from the first point to the second one. If one target is a detail of the other, then it should not cause problems, unless the camera is doing some weird trajectory that introduces parallax issues. Again, a video would help.
     
  5. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    I thought it was something like that. Was just hoping that there was a way to modify it somehow.

    Sure, here you go:
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hmmm... I can't even figure out what's happening in there. How is the second target a detail of the first? It just seems to come out of nowhere. And why does everything go white for a moment? Maybe you could show me the scene view so I can understand what the cameras are doing.

    As for customizing the blend, I'm curious to know what other option there may be when the target LookAt changes, other than lerping between them.

    That said, in CM 2.1.12 (available with Unity 2018.1 beta) we have added some blend customization, and depending on what your cameras are doing it might be applicable to your case. While we're stuck lerping between LookAt targets, we don't necessarily have to lerp the camera position, and that might be the key for you because it will affect the parallax.

    upload_2018-3-6_9-52-41.png

    The spherical and cylidrical options rotate the camera about the LookAt target, instead of doing a straight linear lerp between positions.
     
  7. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    Okay. I'll try again. :D

    I have this big machine. Its center is the LookAt target of the first freelook camera. The second LookAt target is the center of the smaller device which, indeed, is an individual object but basically a detail of the whole machine.

    It seems to come out of nowhere because the rest of the machine along with the 47 instances of the device get moved out of the way when clicking on one of the instances. Also the blending of the cameras start when clicking.
    All devices are attached to the machine in a circular way near the top of the machine.

    It is white for a moment because while blending the cameras it seems to blend the body of the camera a lot faster than the target (or the distance between the two LookAt targets is lower than the distance between the two bodies). So the temporary LookAt target is in a space while lerping where at this point in time there is nothing to see. This would also explain the rather immediate "snapping" of the LookAt target right before the blend is complete (pretty much at the 5 seconds mark in the video).

    I guess there is no way other than lerping from one point to the other. I basically thought there might be a way to individually set the blend time for the LookAt target and the body for example. I think that would be a solution for this problem since it would allow the LookAt target to blend a lot faster than the body so there wouldn't be the awkward white part in the middle of the blend because the target blend would have been completed by then.

    Thanks I will try that. There shouldn't be any problems when moving from 2017.3 to 2018.1 beta?
     
  8. MSachs

    MSachs

    Joined:
    Nov 22, 2017
    Posts:
    122
    And this is happening in the scene view:



    the light is parented to the camera thats why it looks a little awkward ;)

    The problem is not as noticable when both freelook cameras are "on the same side" of the machine when blending.
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Thanks for the vid. I'm thinking that Cylindrical position blending will help you out here.

    As for upgrading, you should take the usual precaution of making a backup first. Always do that before an upgrade.
    Next, the new CM is available in the Package Manager.

    Important: Before installing CM 2.1.12, you must delete the current Cinemachine asset from your project, otherwise there will be metafile hell.

    Let me know how it goes.