Search Unity

How to check when a LookAt Composer is properly oriented?

Discussion in 'Timeline' started by f0ff886f, Aug 12, 2019.

  1. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Apologies for the confusing thread title.

    I am using CineMachine with my own first person controller, right now it generally functions as a DoNothing on Aim and Follow since I take care of setting the transform directly.

    Now, I'd like a moment when my player should look at something specific. I've found that if I create a second vcam and position it in the world directly where my main vcam is, set it to LookAt the target and set its Aim to Composer, then set the priority higher than my main vcam, I get a very nice "LookAt" blend to the right orientation.

    Is there a way to get a notice when composer is actually looking at the target transform, or when that blend is complete? I tried to check for isBlending on the brain, but it returns immediately false all the time. And only the rotation is actually changing since both positions are the same.

    Otherwise, is there a way to force the composer to aim within some time limit? So when I turn on my vcam with lookAt, I know within T seconds it will be oriented properly.

    Thanks!
    Matt
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    There is no notification when a blend finishes, but brain.IsBlending should return true while the blend is in progress. If you set up a custom blend for your LookAt vcam which lasts X seconds, then you can be sure that the blend will be finished X seconds after you activate the LookAt vcam.
     
    f0ff886f likes this.
  3. f0ff886f

    f0ff886f

    Joined:
    Nov 1, 2015
    Posts:
    201
    Do I have to wait a few frames before isBlending will be true? When is a blend "complete" in this case, when the Aim Composer has completely centered on the target?

    Thank you for the info.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,717
    It's possible that you might have to wait a frame or two for IsBlending to become true, depending on the shape of the blend curve. The blend is finished when there is no more input from the outgoing camera (i.e. when the blendCurve value is 1). The incoming camera may or may not still be damping towards its target, depending on the settings.