Search Unity

Different framing for different objects

Discussion in 'Cinemachine' started by Dudledok, Jan 25, 2018.

  1. Dudledok

    Dudledok

    Joined:
    Oct 24, 2013
    Posts:
    110
    I'm working on a 2.5D game with a camera that has a fixed rotation.
    So far I've been using Cinemachine to follow a TargetGroup, but this won't suffice any more.

    What I want is to have my player character on screen at all times and another object on screen if possible with the camera moving / zooming within defined constraints. Most of this is fine, but naturally as the player moves away from the other object the TargetGroup position will be too far away from the player for the camera to keep the player in frame.
    I have a higher weighting on the player, but I can obviously only push that so far, and the same applies with the max ortho size / cam distance.

    What I would like to be able to do is define different framing settings for the player and the other object, and then the camera uses a sort of average / max of the two:
    • The player should always be within shot (plus deadzone)
    • The other object should be within shot if possible (max distance restraint)
    • If the other object is not within shot, the camera shouldn't snap back to the player (for example I don't want to just remove it from the target group if it's too far away)
    • Additionally I'm using some look ahead on the player
    I don't see a way of defining something like this so I thought I'd ask before implementing our own solution.

    Suggestions?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,719
    Here are a couple of ideas:
    1. Dynamically (and smoothly) adjust the group weight of the secondary target, lowering the weight as it moves farther away. When the weight gets to 0 the target will be ignored altogether, and the framing will adjust smoothly at all time.
    2. Use a CinemachineMixingCamera to dynamically mix between 2 different framing algorithms
    Lets us know how this works out for you.
    Regards
     
  3. Dudledok

    Dudledok

    Joined:
    Oct 24, 2013
    Posts:
    110
    I think it will require a more manual solution as both of those options essentially amount to the same idea and neither of them quite work. For example, setting the weight to 0 for the other target would ignore it as you say which I never want, and finding the right weighting balance to update it live is fiddly.
    Thanks for the suggestions though, Using the MixingCamera elsewhere and I really like it.