Search Unity

Question Cinemachine 2D Camera - Pan up and down with right analog stick

Discussion in 'Cinemachine' started by bwaite87, Apr 16, 2022.

  1. bwaite87

    bwaite87

    Joined:
    Nov 23, 2017
    Posts:
    18
    Hey all,

    I'm currently using a simple 2D virtual camera to follow my player in a sidescrolling platformer.
    I'm trying to figure out how to pan the camera slightly up or down based on the input with the right analog stick being pressed up and down.

    has anyone accomplished this? Cinemachine and controlling it through code gets me quite confused..
    Do I need a separate virtual camera to handle this? Or do I deactivate the player from being followed for a moment, and then reactivate it after I'm done panning? Or am I not even close?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    I think the simplest way would be to make an invisible child object of your player, that moves up and down vertically in response to user input. Use this invisible object as the camera target.
     
  3. bwaite87

    bwaite87

    Joined:
    Nov 23, 2017
    Posts:
    18
    That's...genius. I was just about to come close this thinking I posted it to Unity Answers.

    The solution I ended up using was to create a whole other virtual camera with nothing in the body and aim and switching to that camera when needed. I will likely switch to yours though as it's simpler and gives me better control, thanks so much!
     
    Gregoryl likes this.