Search Unity

Question Lock-On Camera with VCam is too sensitive to animation movement

Discussion in 'Cinemachine' started by ranjansikand, Nov 24, 2021.

  1. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    Hello!

    I'm attempting to using a pair of Cinemachine virtual cameras to achieve a Zelda-like lock on system (The Legend of Zelda: Ocarina of Time - Stalfos Battle). So far, I have an orbit camera that reacts to mouse movement, and on input, you transition to a virtual camera (Body: Transposer, Aim: Group Composer that follows player and looks at TargetGroup) that is locked behind the player to face the enemy. It works well overall.

    The issue is that the camera is too sensitive. If you enter any kind of attack animation, the camera flies around for 3 seconds before settling back into position. If I change the damping, it fixes the issue, but it doesn't respond to movement quick enough anymore.

    My desired behavior is for the virtual camera to follow BEHIND the player, only reacting to axis motion, while pointed at the enemy at all times. It should not move during animations unless they significantly move the character's position.

    How can I fix this to look smoother?

    Edit: To clarify, if I change the camera from "Lock To Target With World Up" to any other setting, it stops the violent careening but no longer follows behind the player (i.e. if you walk to the side you'll be looking at the character's face)
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Try changing Transposer to Framing Transposer.

    Another option is to put an invisible proxy object to use as a follow target. Have an invisible object with a script that tracks the player position but with orientation always pointing towards the lock-on target. Then use that as a vcam follow target, with "Lock to Target etc" binding mode.
     
    Last edited: Nov 24, 2021
    ranjansikand likes this.
  3. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    I did try Framing Transposer, but it changed the perspective to have one item on either end of the screen.

    I’ll try the second method. Thanks!
     
  4. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    Hi! I managed to find a method that worked, but it doesn't transition very well -- there are a lot of sharp jumps when moving into and out of the lock-on. I posted a video here, and one of the examples appears at about 4.5 seconds in:


    Do you have any idea how to solve the jarring in transitioning? It "spazzes" and shakes across the screen sometimes when I switch into or out of the desired camera, but I haven't been able to fix that so far.
     
    Last edited: Dec 6, 2021
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    When you tried Framing Transposer, did you do it like this?
    • Body = Framing Transposer, Follow Target = Player
    • Aim = Composer, LookAt Target = Enemy
    If you do that, it will always look past the player at the enemy, i.e. Camera -> Player -> Enemy in a line. Is that what you're trying to get?
     
  6. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    I did:
    Body: Hard Lock to Target (the way you outlined above, with an empty object as the follow target)
    Aim: Group Composer, LookAt TargetGroup which focuses on the target with weight 1, radius 2. I wasn't sure about this, but it worked so I didn't change it.

    The targeting itself is working fine, for the most part, but on switching into and out of the "lock on," the camera tends to jump around or spin before settling into place, particularly if the player is moving away from the lock target when "unlocking."
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    I think you'll get better results with the FramingTransposer/Composer combo. With the group as you have it, you can't control the camera position, so it can do strange things when trying to blend to a position that's rotated a lot. It also looks like you're having some issues with damping.
     
  8. ranjansikand

    ranjansikand

    Joined:
    Apr 8, 2021
    Posts:
    110
    Just tried that, and it does seem to solve a lot of the issue. Thanks!

    There's still quite a bit of keeling when shifting between cameras, but I'll mess around with the values to find something that feels better.
     
    Gregoryl likes this.