Search Unity

Question 2d Cinemachine Camera

Discussion in 'Cinemachine' started by kdrago, May 12, 2020.

  1. kdrago

    kdrago

    Joined:
    Oct 27, 2018
    Posts:
    19
    Hi,

    I'm creating a 2d platformer with different frames for each part of the game, however, the transition does not look great because the camera reaches the edge of the frame before the player and the parallax effect stops at this point, whilst the player is moving towards the edge of the screen.

    Anyone knows how to set up a 2d Cinemachine camera, which follows the player, so that the player is at the edge of the camera at the point that the camera reaches the edge of the confiner.

    Grateful for any help.

    Thanks
     
  2. kdrago

    kdrago

    Joined:
    Oct 27, 2018
    Posts:
    19
    In case others have the same issue, I came up with a sort of solution. It is rather inelegant, but appears to do the trick.

    As the player moves across the screen the m_screenX of the Cinemachine Virtual Camera framing transposer is adjusted at runtime relative to the player movement.

    I am sure that there are better ways of doing this, possibly without any code, but I could not get it to work by adjusting the settings.
     
    gaborkb likes this.
  3. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    The Cinemachine Confiner is what you are looking for.
    There is even a Official tutorial how to use it