Search Unity

[Cinemachine] Damping when changing vcams

Discussion in 'Cinemachine' started by Squize, Apr 10, 2017.

  1. Squize

    Squize

    Joined:
    Jul 17, 2015
    Posts:
    18
    Hey guys,

    So I'm really impressed with Cinemachine so far, it's one of those things that you can tell even with some rough edges currently that it's going to be great.

    I'm going to spoil that praise with a quick question though. Currently I have a top down game with 3 vcams as I want to zoom in / out depending on the action.
    Even though I've turned damping off everywhere ( In both Aim / Composer and Body / Transposer on all 3 cams ) I've found that when blending between cams ( Just by changing their priority around ) there is a really large "lag" where it stops following my main actor.

    It feels like during the blend the tracking falls behind, even though all 3 cams use the same LookAt / Follow transform ( Which is the same for both ) so my player character can really move off screen a lot when I always want him to fixed ( With a small bit of wiggle room ) in the centre.
    If I bring up an in-game UI which pauses the game it does then tween to the correct position. With the active vcam changing a lot it always ends up "playing catchup".

    I'm hoping I'm just doing something dumb, anyone got any ideas please ?

    Thanks in advance,

    Squize.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Sounds like something is pretty wrong. I'd like to try to repro that here. Any chance you can give me a stripped-down scene that shows this?
     
  3. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Wait a minute - you said top-down. Are the vcams looking straight down?
     
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    @Squize , we've spent a tremendous amount of time getting the blending math right for the multitude of possible scenarios.

    Quick example - the math which makes the camera feel right in most scenarios can cause gimbal lock when tracking objects which go straight overhead or straight below the camera. Math which handles those kinds of problems - quaternions - can feel super robotic and non-human in other scenarios. What to do?

    We've done some really interesting stuff to mix the best of both worlds but there's some big challenges conceptually. With a Y up camera, what do you do when tracking a subject which goes straight overhead? Flip the camera around? How fast? If it's too slow you lose composition briefly.. If you don't flip then what, shoot the 'back side' upside down?

    This isn't a Cinemachine rough edge, it's a conceptual one.

    Because we need to build something pretty universal, we have come to a solution which allows for the most versatility. We now let you set the coordinate space of Cinemachine to be anything you want.

    If your game looks down mostly (or up) you can now rotate Cinemachine's space to be at whatever angle you want (and even animate it !!) so a simple 90* x rotation on the Cinemachine World Up object will keep all the blending/tracking in the 'sweet spot' of the math. "Up" for the camera is now "Straight ahead", so the gimbal cones-of-death can be rotated to always be below the camera, away from where most of the action is.

    The feature is done, we're testing it now. Super handy for RTS games or anytime you don't want to shoot stuff which tends to hang around a horizontal-ish sort of space relative to the camera.

    It will be shipped with Cinemachine V2.0, delivered to the Asset Store, in a few weeks.
     
    Squize likes this.
  5. Squize

    Squize

    Joined:
    Jul 17, 2015
    Posts:
    18
    Hey guys, thanks for the prompt replies.

    I can't really strip down the project, but I've done a quick capture of it.
    https://www.dropbox.com/s/9gxu81szw28ycf6/cineMachineCapture.mp4?dl=0

    The difference between the cams is pretty subtle, but as we change between the 3 vcams in the scene you can see how the target ( Hank the cop ) is no longer tracked in the middle of the screen.

    I've uploaded a grab of my settings, all 3 cams are pretty much the same, just with a different offset in the transposer ( Basically I want the game to zoom out if there aren't many baddies close to you, and also zoom in close if the player is under attack )

    In terms of code it's as simple as:

    if (amount<=14) {
    vcam_upClose.m_Priority = 3;
    vcam_default.m_Priority = 2;
    vcam_far.m_Priority = 1;
    }
    else {
    if (amount == 18) {
    vcam_far.m_Priority = 3;
    vcam_default.m_Priority = 2;
    vcam_upClose.m_Priority = 1;

    }
    else {
    vcam_default.m_Priority = 3;
    vcam_upClose.m_Priority = 2;
    vcam_far.m_Priority = 1;
    }
    }


    I'm guessing I'm just doing something really dumb.

    Cheers.

    PS. Adam, really looking forward to v2 mate, it is a really great system.
     

    Attached Files:

  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    @Squize Thanks for the vid. I see the places where the guy goes away from center. Some questions:
    - What are the transposer offset settings for the 3 vcams?
    - What are the FOV settings on the 3 vcams?
    - If you change the composer of the 3 vcams to "hard constraint", does the problem go away?
    - I assume that the transitions we see in the vid are between default and near vcams. Is that correct? (you can enable "show debug text" in the CinemachineBrain to help keep track of what's going on)
     
  7. Squize

    Squize

    Joined:
    Jul 17, 2015
    Posts:
    18
    Hey Greg,

    I've attached my 3 settings, only really minor changes between them all. My blend times are 2 seconds or so, and it feels like that's where the lag, for want of a better word, is in that if I pause the action so no cameras are being swapped it does seem to take that length of time to "catch up" if that makes sense.

    Upload doesn't seem to be working, so here are the drop box links for the settings.

    https://www.dropbox.com/s/bg7cqcfk4hizx8q/cineMachine_transposerFar.png?dl=0
    https://www.dropbox.com/s/8rpfm2iofjmeljn/cineMachine_transposerClose.png?dl=0
    https://www.dropbox.com/s/61pzr6mnm1np5e6/cineMachine_transposerMain.png?dl=0

    - Hard constraint with no offset just put me too close to the action
    - Yeah in the clip it's near and main ( Default )

    It feels like during a blend it's not constantly updating it's target, like it captured the position at the start of the blend and aims there.

    I hope that's some help, if there's anything else you'd like please let me know. Thanks for the help with this, I am grateful.
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    @Squize
    - I meant hard constraint for the Aim, not the Body. No matter, though, because I know what's wrong.
    - I'm pretty sure your problem is because of FOV. To fix: give all 3 vcams the same FOV, and change the Transposer offsets to put the vcams at near, medium, and far distances (instead of zoom, you will have a dolly).
    - This fix is a temporary workaround. The FOV not blending properly is a known issue, already fixed in Cinemachine 2.0
     
    Squize likes this.
  9. Squize

    Squize

    Joined:
    Jul 17, 2015
    Posts:
    18
    Thanks mate, but still no difference ( With hard constraint on Aim / matching FOV for all 3 cams ). I even tried changing the blend times to 0 but it was still happening.

    Cheers for looking into it, but if v2 is just around the corner I can hold fire, it's not mission critical or anything.
     
  10. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Your issue is very puzzling, and I'd like to get to the bottom of it.
    Is it possible that you're not really tracking the main dude, but some other game object? How does CenterPoint relate to the character? If you set the LookAt and use a hard constraint in the aim, then the thing you're looking at will *always* be in the center of the frame, no matter where the camera is placed or what the FOV. Under the hood it's just doing a LookRotation in that case. I'm beginning to think that you're looking at the wrong object.
     
  11. Squize

    Squize

    Joined:
    Jul 17, 2015
    Posts:
    18
    I've attached a grab of my hierarchy / character in scene, I think I actually added the centre point ( Which is just a Sphere Collider set as a trigger for a simple visual test ) just for the vcams as they were aligning to the characters feet due to his pivot point.

    I just tried pointing directly to the parent Player gameObject and removed the custom blends from the brain, and also double checked that my old camera follow code wasn't still running, and the same thing.

    In theory this shouldn't be too hard to replicate, I'm not doing anything super clever. So it'd be the 3 vcams that I posted yesterday, and a simple movement script for a game object and then just using the priority swapping code I posted under a key press ( Sorry, I'm swamped and don't have the time to knock it up myself ).
    If you can't replicate it with that then it's all good, it'll obviously be something stupid I've done ( Which is the more likely case :) )
     

    Attached Files:

  12. Squize

    Squize

    Joined:
    Jul 17, 2015
    Posts:
    18
    Good news, it was me being crap :)

    Under my own code I was Lerping between the field of view values so it was smooth, but when I dropped CineMachine in there I just assumed I could fire off a value and it would tween the FOV / position for me.

    Putting the lerp back in, so instead of every frame possibly hitting it with a new value, it eases between the values now and tracks properly. I'm also going to add a check to only change the camera priority if need be ( Again, something I was doing every frame ).

    Thanks for your help with this Gregoryl.
     
    Adam_Myhill likes this.