Search Unity

Change this script to lerp euler angles?

Discussion in 'Scripting' started by Treasureman, Nov 27, 2015.

  1. Treasureman

    Treasureman

    Joined:
    Jul 5, 2014
    Posts:
    563
    I have a code that changes a certain variable in a certain code when you hold an input. Here's the script (it won't let me insert codes for some reason)...

    var left : float = -0.75; //determines amount of zoom capable. Larger number means further zoomed in
    var right : float = 0.75; //determines the default view of the camera when not zoomed in
    var smooth : float = 17; //smooth determines speed of transition between zoomed in and default state
    var orbitOTS : MouseOrbitOTS;
    orbitOTS = gameObject.GetComponent( MouseOrbitOTS );

    private var zoomedIn = false; //boolean that determines whether we are in zoomed in state or not

    function Update () {
    if(Input.GetButtonDown("Switch Shoulders")){ //This function toggles zoom capabilities with the Z key. If it's zoomed in, it will zoom out
    zoomedIn = !zoomedIn;

    }

    if(zoomedIn == true){ //If "zoomedIn" is true, then it will not zoom in, but if it's false (not zoomed in) then it will zoom in.
    orbitOTS.xOffset = Mathf.Lerp(orbitOTS.xOffset,left,Time.deltaTime*smooth);
    }

    else{
    orbitOTS.xOffset = Mathf.Lerp(orbitOTS.xOffset,right,Time.deltaTime*smooth);

    }

    }

    How would I change it to rotate a euler angle? thanks!