Search Unity

Maintain dead zones for the Player when using a TargetGroup as the target

Discussion in 'Cinemachine' started by default_team, Feb 14, 2019.

  1. default_team

    default_team

    Joined:
    Dec 1, 2018
    Posts:
    21
    It's a 2D game and I'm using a perspective camera with body set to framing transposer.

    I have a cinemachine vcam with 'follow' set to a target group. At start the TargetGroup has Player as the target. Once Player is close to the Portal within certain distance, I add the Portal to the TargetGroup with weight of 1. So the camera position at the center of the group. And that's intended

    With the default settings, the camera is too close to the Player, so I increase the min FOV. And decrease max FOV to constraint the camera from zooming out too much. I also adjust dead zones, so to keep minimum distance between the Player and the screen edges.

    When Player gets further away from the portal, the camera zooms out and position at the center of the group. So the Player and the Portal ends up in the left/right edges of the screen, which is not what I want. Adjusting the dead zones didn't seem to help as the camera follows the TargetGroup instead of a single target.

     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    The dead zone is currently ignored when the target is a group. We're working on changing that, but for the time being, the way to control it is to adjust the Group Framing size.

    upload_2019-2-14_8-57-36.png
     
    default_team likes this.
  3. default_team

    default_team

    Joined:
    Dec 1, 2018
    Posts:
    21
    But that depends on the 'Maximum FOV' property right? I don't want the camera to zoom out too much.

    As for now I attached a script to the TargetGroup to adjust the weights of the each target by its distance to the player. That helped to keep the player within the screen. This is a turn based game, so I make it to adjust the weights after each move.

    But the camera looks overdone though, as the weights change a lot. Can I damp the zooming BTW?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    The Z damping will damp the zooming.
    Yes, overdone cameras are not very nice.
    Another possible approach is to have a single item in the group (the player) and adjust the radius dynamically. That will keep the player always in the center. Don't know how appropriate that is for your game.
     
    default_team likes this.