Search Unity

Change Camera Distance As Rotation Changes

Discussion in 'Scripting' started by christopherjon, Apr 11, 2021.

  1. christopherjon

    christopherjon

    Joined:
    Mar 8, 2014
    Posts:
    11
    I'm trying to recreate the same effect as the Cinemachine Orbit Rigs.

    As the camera rotates up or down its distance to the player decreases.

    I know it should be something along the lines of as the rotation value increases the distance decreases with a little lerp to smooth it out but I'm missing something.

    Point me in the right direction as my brain is a little fried at the moment.

    Thanks!
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,674
    If I understand your description, you can kinda get this for free if you pivot an extra Transform AT the player's location, and then offset based on that Transform to drive your camera location, making the camera effectively stay within a sphere around the player.
     
    The-Peaceful likes this.