Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question 2D Game: How to have camera follow player only if player moves in one direction?

Discussion in 'Cinemachine' started by antonioniii, Oct 5, 2023.

  1. antonioniii

    antonioniii

    Joined:
    Jun 15, 2020
    Posts:
    27
    Here is the game I'm using for reference for my game project.
    You'll see that the camera will move as the player moves up but does not follow them as they go down

    https://guselect.itch.io/cheese-bit

    . How can I config Cinemachine for this same effect/outcome?

    Here's a video of my current Cinemachine configuration to emulate this. However, when my player falls down, the camera follows as expected. How would I go about locking it to only an increased Y value?

     
  2. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    156
    Heyyoo :) ,

    I don't think there is a way to do it with cinemachine components. However in your case you could create an empty gameobject that could simulate where the camera should be.
    If the player goes up the target matches the position. If it goes down you stop updating the target.

    Would that be a viable option?
     
    Gregoryl and antonioniii like this.
  3. antonioniii

    antonioniii

    Joined:
    Jun 15, 2020
    Posts:
    27
    Oh wow! I think that will work just fine… thank you for the great idea! .

    I need to be able to think more outside the box like this :D