I have a script that changes the variable ‘yOffset’ in my code ‘MouseOrbitOTS’ from 0.0 to 0.2 when you hold the ‘Aim’ input. Here’s that script…
var NormalY: float = 0.8; // XOffset while not aiming
var AimY: float = 0.7; // XOffset while aiming
private var cameraScript: MouseOrbitOTS;
function Start(){
cameraScript = GetComponent(MouseOrbitOTS);
var ch:Camera = GetComponent(Camera);
}
function Update(){
var cameraY = NormalY;
if (Input.GetButton("Aim")){
cameraY = AimY;
}
cameraScript.yOffset = cameraY; // set XOffset while aiming or not aiming
}