Search Unity

keeping Follow target centered during LookAt transition

Discussion in 'Cinemachine' started by JoeJoe, Jul 3, 2019.

  1. JoeJoe

    JoeJoe

    Joined:
    Mar 22, 2013
    Posts:
    8
    I'm aiming for cameras that keep the player firmly at screen center, to prevent motion sickness.

    Most of the game uses a fixed camera. A bit above the player, with a fixed orientation and Z offset. You can run toward the camera, it doesn't re-orient. No lookahead, no damping.

    I'm using HardLookAt for Aim, Transposer for Body bound to WorldSpace. Both Follow and LookAt are aimed at the same point in the player's torso. Nice simple control of camera position and aim.

    Occasionally I want to transition to a camera with a different LookAt target, to focus on a point of interest. (Movement control is camera-relative, so you can orbit the point by moving left-right.) For this I'm using a Framing Transposer for the Body to keep the camera oriented on the player at roughly the same fixed distance as the default camera, and a HardLookAt for the Aim with a new LookAt target.

    I'd like to keep the player exactly at screen center when the cams transition. So as the camera rotates to aim at the new LookAt target, it also repositions to keep the Follow target strictly centered.

    I can't figure out how to keep the camera locked on the Follow target as it reorients/repositions. It lands in the right place, but in-between, the player goes off-center. I've experimented with different algorithms & settings, no luck so far. Feels like I'm missing something(s).

    Sweet explanatory graphic enclosed. Any insights appreciated.
    Joe
    camTransition.jpg
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Normally, when you use the Framing Transposer, you don't put anything in the LookAt. You are doing something unusual (but interesting!)

    When you change the LookAt target, the LookAt point will lerp from the first target to the second, and the HardLookAt behaviour will override the Framing Transposer's attempts to keep the player centered.

    I would get rid of the HardLookAt, and instead just manually lerp the vcam's rotation towards the new target.
     
    Last edited: Jul 3, 2019
  3. JoeJoe

    JoeJoe

    Joined:
    Mar 22, 2013
    Posts:
    8
    I know right? LookAt target is supposed to be null. For some reason that combo gets me closest to what I'm after.
    Thanks for the info. I'll try a lerp.
     
  4. JoeJoe

    JoeJoe

    Joined:
    Mar 22, 2013
    Posts:
    8
    Well that could not have been easier! I took out HardLookAt, added transform.lookat to the vcam and let cinemachine do the lerp. Boom.

    I've been shy about moving cameras by myself, kinda intimidated even though my needs are basic. Now I've dipped in and it's fine. Thanks for the nudge.
     
    Gregoryl likes this.