Search Unity

Need a bit of help getting started

Discussion in 'Cinemachine' started by john_hattan, Jan 24, 2018.

  1. john_hattan

    john_hattan

    Joined:
    Aug 28, 2013
    Posts:
    11
    So I decided it was time to take the plunge and start dealing with Cinemachine. While very powerful, it's a bit daunting compared to the standard Unity camera, and I need a little help getting started.

    I have a 2D+3D voxel puzzle game. To give you an idea, this is a Sokoban level being played on it. This will be the default view when the user starts a level.

    (also, this is a really old screenshot. I'm just being illustrative)

    (and for some reason the images aren't linking.)

    http://www.thecodezone.com/temp/Capture2.webp

    If the player flicks up and down on the screen, it'll switch from the view above (35-degree orthogonal) to a 45-degree orthogonal, to a 90-degree orthogonal, which makes it appear to be a 2D game..


    If the player flicks left and right, the board rotates. The arrow keys control the vehicle.

    http://www.thecodezone.com/temp/Capture1.webp

    Finally, you can pinch to zoom in or out. Ideally I'd like to have the pinch zoom in on the vehicle that you're currently controlling. And if you switch vehicles, the screen will pan smoothly to the vehicle that's got focus.



    http://www.thecodezone.com/temp/Capture.webp

    With the standard camera, the pitch-and-yaw wasn't difficult. I just looked at the center of the board and then rotated the camera in the Y or Z direction. Pinching in to a vehicle seemed like a natural for Cinemachine, as I can let the virtual camera follow a vehicle as it moves, keeping it in the center.

    Anyway, I'm rather at a loss as to even how to get started on this. It seems like having multiple virtual cameras for each angle would be making things more complicated than I need.

    I'm trying to follow the documentation, but it doesn't seem well suited to a game like this. I'm not even sure what would be the proper virtual camera to use.

    Anyway, if anyone's got some advice, I'd love to hear it. Right now I'm just struggling around, and I'd welcome any pointers in the right direction.
     
  2. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    Your answer is in multiple virtual cameras. This is the spirit of Cinemachine, you make lots of cameras which do exactly what you want in any given situation, instead of building one giant ball-o-code mess of a Swiss army knife camera which is a pain to tune and is a fragile bug-factory.

    Look at every section of your game which wants some camera variation, make a camera for that bit and blend in and out of the cameras as the player progresses. You can blend in and out of them by simply turning the cameras on. If they're the same or higher priority, they'll blend in.

    By default, the blend time is 2 seconds but you can get really specific. You can easily create specific blends between any two cameras, there's also wild cards - from 'any' camera to a specific camera can have a custom blend. Etc. etc.

    We made the Custom Blends an asset, so you can have unique setups per level.

    It's all under the Cinemachine Brain, which is a component that's applied to the main Unity camera.

    upload_2018-1-24_20-58-3.png

    See the custom blends above, setup any kind of transitions you want.

    Since only the active vcams cost anything, and they're super cheap as it is, you can have lots of them, all over the place. Please do! That's how Cinemachine is meant to be used.

    Crazy example, on one game, I've had 50+ virtual cameras for a single level. The cameras did exactly what I wanted EVERYWHERE.

    Some of the blends were just subtle changes - screen composition or a little bit of zoom. Create a new camera and blend to it whenever you want to make even the smallest tweak to best support the gameplay or cutscene.

    Hopefully that help! Let us know how it goes.
     
  3. john_hattan

    john_hattan

    Joined:
    Aug 28, 2013
    Posts:
    11
    That'd be 24 identical virtual cameras (3 perspectives * 8 rotations) all arranged around the board like a big dome and pointing at the center. And stuff like pinch-to-zoom would change the orthographic size on all 24 cameras.

    I'm wondering how that'd be easier than having one camera that I tween around into different perspectives and rotations. Should I create all of the cameras at runtime, because creating and placing and setting up all 24 cameras seems like it'd be pretty unruly?

    Anyway, thanks for the advice. I just got used to Unity cameras when Cinemachine became the preferred way of doing things :)
     
  4. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    It is one camera you're tweeing around - the main camera :) . You're using the virtual cameras to define exactly what you want the main camera to do at any given point.

    The 'tweening' is the custom blending between different virtual cameras. WAY more control. Try it !