I have a script that lerps a variable called ‘xOffset’ in the script ‘MouseOrbitOTS’ when an input is pressed. Here’s the script.
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);
}
}
I want to change it so instead of tapping the input, you hold it in. I know it’s a pretty stupid question, but I’m somewhat new to scripting (not new, more like never officially taught). I know it’s a very easy thing to do, and I hope I’m not asking for too much, but could someone convert it? Thanks!