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

Camera following player, how do get it to stop after the player falls?

Discussion in 'General Discussion' started by kingkill97, Feb 10, 2021.

  1. kingkill97

    kingkill97

    Joined:
    Feb 20, 2019
    Posts:
    8
    Hey There pees I have a question about camera... I'm using Cinemachine to have a smooth cam but when let say when the player falls the camera falls with him. So my question is how can i get the cam to stop following the player at a key point? I have a box collider there so when player hits it the cam doesn't follow. But im lost at what to do. Thanks for the help!


    camfollow.png game.png
     
  2. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Use a bool. "if(followingPlayer)"

    Set it to false when they fall, and true when they get back up.
     
  3. mauser100

    mauser100

    Joined:
    Oct 13, 2016
    Posts:
    13
    alternative would be a bool to follow if the player's y position is above a certain amount
    if(target.position.y > -2) //or whatever
    {transform.position = target.position + offset}
     
  4. EternalAmbiguity

    EternalAmbiguity

    Joined:
    Dec 27, 2014
    Posts:
    3,144
    Hope his/her game is just a flat plane :p