Search Unity

Ideas on achieving this specific camera behaviour

Discussion in 'Cinemachine' started by Mangonels, Sep 27, 2018.

  1. Mangonels

    Mangonels

    Joined:
    May 8, 2018
    Posts:
    20
    An image is worth more than a thousand words, so I'll just say I want to replicate the camera movement in paper mario ttyd for a 3D game I'm making:

    https://i.imgur.com/6HHj0I3.gifv

    Description:

    - The camera moves further towards the left as the character moves to the left, and further to the right, as the character moves right, in a "lookahead" kind of way, but it doesn't return back to align with the character, nor does the camera actually rotate in order to look ahead, it's actually moving forward, and stays looking ahead unless you turn back, then it progressively goes back towards the opposite side. It only does the lookahead left to right and viceversa, and it has a limit.
    - The camera doesn't keep moving further on on it's own, nor does it move back to center with the character if it isn't moving (Allthough it would be nice to do this last thing forcedly in some situations/command).
    - The camera moves inmediately accompanying the character in the X and Z axis, but it actually doesn't accompany inmediately when moving up and down on Y (There's a vertical threshold after which the camera does start accompanying) since mario jumps a lot, and that would make the camera bounce on every jump.
    - There are also tridimensional camera movement bounds, but I'm guessing that can be achieved easily with a box collider as confiner.

    I know I'll have to tweak cinemachine extensively in order to get it right, but I would appreciate some overall ideas, since I already tried some obvious stuff. If however, the advice is to use a specific cinemachine camera and code the rest of the behaviour, I guess I can think of something, I just want to know if there's some easy ways to accomplish this level of camera polish.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I would set up 2 CM cameras, one with the framing a little to the left, and the other with the framing a little to the right. Activate one or the other according to the player's direction of motion. You can have a third one that's centered if you like, and activate it when appropriate. Adjust the Brain's blend settings to get the transitions you like.

    For the vcams, use a Framing Transposer in the Body, and Do Nothing in the Aim. Put a dead zone to prevent the camera moving right away, and a soft zone all around to get nice follow motion after the player moves far enough.

    And yes, to confine the camera, use a Confiner extension with a box shape to delimit the region where the camera can go.

    Good luck, and do post here with your results.
     
    Mangonels likes this.
  3. Mangonels

    Mangonels

    Joined:
    May 8, 2018
    Posts:
    20
    There's a few problems with doing what you suggest though, due to the specificities of what I'm trying to do.
    I can't make the camera blend stay between two cameras if the player stops moving. Let's say I walk left, for 1 second, and the camera takes 2 seconds to pan from center camera to left camera, the blend won't/can't stay between the two right? Afterwards the blend should resume if the player movement continues in the same direction, or in the opposite direction if the character starts moving right.
    For this, I thought of an alternate system setting up a dolly track and making the camera go left on the track as long as the character is moving left, but this raises some more issues, like the dolly track having to be assigned to a position relative to the player and thus making it rather rigid in the depth axis.

    Still, I think If I could just freeze the blend in it's spot maybe that would be enough, as long as it blends in the right direction afterwards if priorities change.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Maybe you should have a look at CinemachineMixingCamera. It's purpose is to generate a continuous blend of its vcam children. Have a left child and a right child, and drive the blend weights according to your own formula.
     
    Mangonels likes this.
  5. Mangonels

    Mangonels

    Joined:
    May 8, 2018
    Posts:
    20
    That did the trick, thanks a lot for everything. This is how it's doing:

    So around 0:42 I attempt rotating the cameras downwards for a better view of the character and scene, but this makes them fly up and down on Z axis movement... How can I get a better downward view without this happening?
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    can't see your video. is it private?
     
  7. Mangonels

    Mangonels

    Joined:
    May 8, 2018
    Posts:
    20
    oops. It's public now.
     
  8. Mangonels

    Mangonels

    Joined:
    May 8, 2018
    Posts:
    20
    Also, in cases where the character ascends on top of objects the camera stays a bit low... I can't find a right combination of limits which also respects the player jumping (No accompanying on jump):


    I'd like the behaviour in these cases to be something more like this.
    https://i.imgur.com/oQL9jU8.mp4

    Description:
    Jumping on higher or lower planes should make the camera ascend or descend to an appropiate character level, the "camera leveling" should occur as soon as is grounded.
    The main issue here is how to get the 3 cameras to level to the player's new grounded height efficiently.

    Currently the camera already positions itself level with the character on descent thanks to the lower softzone limit, but not on grounded ascent.