Search Unity

Problem: Blending between two cameras with the same lookat target has unexpected behavior.

Discussion in 'Cinemachine' started by wackyDev, Mar 24, 2019.

  1. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    I have been troubleshooting this for a while and have narrowed down my problem to the following. When blending between two cameras with the same lookat target, the new camera uses its final position(after blend) to calculate the lookat camera rotational values. Now because the new camera starts behind the lookat object and ends infront of it, the camera begins to rotate away from the object in the beginning of the blend turning away from the object.

    Hopefully this makes sense let me know if you need more info. Maybe this is the correct behavior in which case is there any way to only blend camera positions while cutting directly to the new(same) lookat target?

    Thanks for any help!
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    A picture or diagram would help.
    You say the new vcam starts out behind the target and ends up in front of it. You mean the incoming vcam is moving? Where is the outgoing vcam?
    Or are you saying that the (static) outgoing vcam is behind the target and the (static) incoming vcam is in front of it?

    Just stabbing in the dark: try enabling a blend hint on the incoming vcam, to stop the vcam position lerping through the target:

    upload_2019-3-25_10-19-38.png
     
  3. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    "Or are you saying that the (static) outgoing vcam is behind the target and the (static) incoming vcam is in front of it?"
    Yeah I think this is it.
    Here is a bad drawing of the situation.
    https://imgur.com/6XynZPi



    When vcam2 is enabled I disable vcam1. They both have the same lookat target and then vcam2 starts to rotate away from its lookat target. It will at the end of the blend be looking in the right spot but I lose sight of the projectile for about half a second. So far I've tried setting the other blending options and resetting the lookat target during the blend but it doesn't help.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Can you show me the inspectors for the vcams? Normally in such a situation they should not look away from the target during the blend.
     
  5. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    Sure I'll attach a video too.


    inspectors, the first photo is vcam2
    https://imgur.com/a/0BjS3HJ

    EDIT: sorry video was set to private, should work now.
     
    Last edited: Mar 25, 2019
  6. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    The blend on the brain component is set to linear t=1s, and the blend hint is set to none on both cams.

    Also, I have follow zoom enabled on vcam2
     
    Last edited: Mar 25, 2019
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    It's a little hard to tell what's going on from the video. It looks as though the camera starts and end at the same spot. That's different from what you described earlier.

    Maybe as an experiment you can simplify some things.
    Set the vcams up without follow-zoom or composer. Just a HardLookAt in Aim at the target, DoNothing in everything else. What does that give?

    Also, maybe a movie that includes both game view and scene view, with the scene view set up so that the camera motion is clear, maybe a top view with an ortho projection? Select the main camera so that we can clearly see the camera frustum travelling.
     
  8. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    Ok I tried the hardlookat and turning off the other settings and it didn't have an effect. I watched the main camera in the scene view and about halfway through the blend is when it is furthest turned away from the ball. By the end of the blend it turns back. I'll try to use unity recorder I think it can capture scene view video.

    "It looks as though the camera starts and end at the same spot."
    The cameras are like 3 units apart it's just hard to tell it's moving forward in the video.
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    You can try 3rd-party screen recorders, or just a few static screen capture frames at key points.
    Is it possible that the target is just going very high up? What does it look like from the side view?
     
  10. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    Here are the screenshots
    https://imgur.com/a/kPvcRGk

    I am not entirely sure what you mean but the target does shoot up fairly quickly.
     
    Last edited: Mar 25, 2019
  11. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    the first photo in the sequence is square with the ball, i noticed it's kind of hard to tell haha
     
  12. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Can you try moving the cameras to safer places, with the vcams and the target making a nice big equilteral triangle on the plane just as a test to see where the problem is coming from. I'm thinking that you're asking the cameras to follow a very strange path.

    I know you're making an effort, but it's really hard for me to tell what's going on just from your images.
     
  13. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    Ok I'll try to be more clear and I can send you a video of the game view if that helps. And thanks for taking time to help, I appreciate it. I put the cameras on the same xy plane and positioned them two units to the right of the ball. The ball just barely stays on the screen and it still pulls to the left, but not as much. It seems to me like the new camera(enabled) is lagging behind the moving target. The soft zone radius is fairly small but maybe there is another setting to keep it on screen?
     
  14. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I don't know what you mean by "2 units" because I don't know how big anything is in your scene.
    Try a layout something like this, on the plane, keeping all the distances very far:
    upload_2019-3-25_16-33-26.png
    Keep the HardLookAt for now, to eliminate any damping etc.
     
  15. wackyDev

    wackyDev

    Joined:
    Feb 20, 2019
    Posts:
    15
    Ok I figured it out. So in the game we have a user input cam and then vcam1 (cam that will be disabled) to show the throwing ball animation followed by the ball follow camera(vcam2, camera being enabled). The problem is that vcam1 was getting disabled in under .25 seconds.. So it was still blending between the user input cam and vcam1(behind user camera) when I enable vcam2. I added in a cut transition between user input and vcam1 and it works now.

    vcam0(user input)->vcam1->vcam2 all blending together!

    So you can get weird behavior if you enable and disable cameras before a blend has completed is the point I think.

    whoops. Sorry, and thanks for helping me figure this out!
     
    Gregoryl likes this.