Search Unity

  1. Get all the Unite Berlin 2018 news on the blog.
    Dismiss Notice
  2. Unity 2018.2 has arrived! Read about it here.
    Dismiss Notice
  3. We're looking for your feedback on the platforms you use and how you use them. Let us know!
    Dismiss Notice
  4. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Learn more.
    Dismiss Notice
  6. ARCore is out of developer preview! Read about it here.
    Dismiss Notice
  7. Magic Leap’s Lumin SDK Technical Preview for Unity lets you get started creating content for Magic Leap One™. Find more information on our blog!
    Dismiss Notice
  8. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

Cinemachine 2D Parallax Question.

Discussion in 'Cinemachine' started by Gamingbir, May 30, 2018.

  1. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    70
    Hi, guys I was wondering If I can achieve this kind of effect using cinemachine. If so please tell me how?
    Below is an example of what I am trying to achieve.
    https://cdn.discordapp.com/attachments/429678342623461387/450094981236129825/2018-05-26_20-34-53.mp4

    Here is the list of things I am trying to achieve:
    1) Make the background follow the player and adjust its height according to a player position in the world like higher when jumping etc.
    2) Repeat background parallax effect. Example the elements in this picture: https://gyazo.com/56c9630ba95dd68c1ef759ea128a4796
    3) Make the camera focus the player like in super Mario world. It focuses on the player and adjusts its camera according to the player moving right or left. Link:
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,425
    Have a look at this tutorial, it should answer a bunch of your questions: https://unity3d.com/learn/tutorials/topics/2d-game-creation/2d-follow-camera-w-cinemachine

    For the parallax effect, just use a perspective camera even though it's a 2D game, and set the depths of your background elements appropriately to get the effect automatically.

    To have the camera not move when the player is jumping, increase the vertical dead zone.

    To have different camera behaviours depending on what's going on in the game, here is the most important thing you need to know: don't try to do it all with one virtual camera. Make multiple virtual cameras, each specialized for a specific mode, and activate them when it's time for them to take over. Cinemachine will blend seamlessly between them. You can control how they blend with the Blend settings in CinemachineBrain.
     
    Gamingbir likes this.
  3. Gamingbir

    Gamingbir

    Joined:
    Apr 1, 2014
    Posts:
    70
    The parallax element will adjust its height like this? I am not sure how they do the repeating parallax elements adjust according the player position in game world. Like what happens when the player goes up or down etc. Thanks for your reply.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    1,425
    Imagine that the scene elements are made of paper, and are placed not all on the same plane, but at different depths from the camera. When the camera (which is a perspective camera, not an orthographic one) moves from side to side or up and down, the scenery elements will naturally show parallax effects, because of their varying distances in Z from the camera.