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.

Question How to make camera follow a path ?

Discussion in 'Cinemachine' started by Naxo175, Mar 12, 2023.

  1. Naxo175

    Naxo175

    Joined:
    Jan 9, 2021
    Posts:
    10
    Hi, I want that my camera follows a custom path but also follows my player's X position. So if my player goes right, the camera will follow the path that is at the same position as the player, and if he goes left, the camera will go left while following the path. I don't know if you understand me, I will try to find a game that does what I want.
     
  2. JeffG

    JeffG

    Joined:
    Oct 21, 2013
    Posts:
    64
    Have both camera's defined. If player turns right raise the priority of the follow camera, if he turns left raise the priority of the dolly tracked or path camera
     
  3. Naxo175

    Naxo175

    Joined:
    Jan 9, 2021
    Posts:
    10
    Thanks for the reply. My problem is I don't know how to make the dolly track camera go forward or backward when the player moves.
     
  4. Naxo175

    Naxo175

    Joined:
    Jan 9, 2021
    Posts:
    10
    To understand a bit better what I want, it is like the custom auto-scrolling feature in Mario Maker 2. The camera moves along the path that the level creator defined. In my game, I want the exact same thing but without auto-scroling. I want that the camera wait for the player to go forward or backward.
    Demo :
     
  5. Naxo175

    Naxo175

    Joined:
    Jan 9, 2021
    Posts:
    10
    I found the solution. I just activated Auto Dolly on the CinemachineVirtualCamera component.
    upload_2023-3-12_19-50-36.png

    Also, I don't know if I must open a new thread, but I would like to set up some waypoints where the camera zoom in or
    out on the player.
     

    Attached Files:

  6. JeffG

    JeffG

    Joined:
    Oct 21, 2013
    Posts:
    64
    Use an IsTrigger collider. OnTriggerEnter, zoom in OnTriggerExit, zoom out
     
  7. Naxo175

    Naxo175

    Joined:
    Jan 9, 2021
    Posts:
    10
    Thanks, I will try this :)