I’m trying to work on a script for switching shoulders using Mathf lerping. Here’s what I’ve done so far…
var left : int = -0.75; //determines amount of zoom capable. Larger number means further zoomed in
var right : int = 0.75; //determines the default view of the camera when not zoomed in
var smooth : float = 5; //smooth determines speed of transition between zoomed in and default state
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.
MouseOrbitOTS.xOffset = Mathf.Lerp(MouseOrbitOTS.xOffset,left,Time.deltaTime*smooth);
}
else{
MouseOrbitOTS.xOffset = Mathf.Lerp(MouseOrbitOTS.xOffset,right,Time.deltaTime*smooth);
}
}
My problem is, I get these errors that I don’t know how to fix…
Assets/SwitchShoulders1.js(14,15): BCE0020: An instance of type ‘MouseOrbitOTS’ is required to access non static member ‘xOffset’.
Assets/SwitchShoulders1.js(14,50): BCE0020: An instance of type ‘MouseOrbitOTS’ is required to access non static member ‘xOffset’.
Assets/SwitchShoulders1.js(18,15): BCE0020: An instance of type ‘MouseOrbitOTS’ is required to access non static member ‘xOffset’.
Assets/SwitchShoulders1.js(18,50): BCE0020: An instance of type ‘MouseOrbitOTS’ is required to access non static member ‘xOffset’.
I know it involves making a static variable, but I’m not sure how to do that. Could someone just add the variable to the code. Thanks!