Search Unity

How to limit the angle of a freelook camera

Discussion in 'Cinemachine' started by Radiago, Sep 18, 2017.

  1. Radiago

    Radiago

    Joined:
    Jan 7, 2014
    Posts:
    18
    Hi, I'm wondering how any of you would approach doing something where you could limit the angles around the x-axis of a freelook camera? I'm trying to achieve something akin to looking through a keyhole or a grate, and cinemachine has been great so far but I'm running into trouble with this. I tried limiting the axis via the SetThresholds function but it appears that is done in world-space, and I'm really looking to do it in local space as part of a prefab. I've thought of just adjusting the bias value and doing the clamping on my own before I set it, but I was wondering if there was a better way or maybe a different direction or starting spot that I hadn't thought of. Any help is much appreciated!
     
    Mrtreeman likes this.
  2. Radiago

    Radiago

    Joined:
    Jan 7, 2014
    Posts:
    18
    Ok, had a thought this morning that turned out to work. I just added a piece to my script that sets the thresholds, to also change the bias heading based on the root transform's rotation. Worked beautifully. Replying here for prosperity and I suppose to share the knowledge. Thanks for making such a great camera system guys, I love it!
     
    Mrtreeman, azevedco and Adam_Myhill like this.
  3. Mrtreeman

    Mrtreeman

    Joined:
    Jun 14, 2021
    Posts:
    1
    Thanks, that helped a bunch!
     
    Radiago likes this.