I’m working on a script that lerps a variable titled ‘yOffset’ in a script called ‘MouseOtrbitOTS’ when an input is held. Here’s my script as it is…
var zoom : float = 20; //determines amount of zoom capable. Larger number means further zoomed in
var normal : float = 60; //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
var orbitOTS : MouseOrbitOTS;
orbitOTS = gameObject.GetComponent( MouseOrbitOTS );
private var zoomedIn = false; //boolean that determines whether we are in zoomed in state or not
//This function toggles zoom capabilities with the Z key. If it's zoomed in, it will zoom out
function Update()
{
zoomedIn = false;
if( Input.GetButton("Aim"))
{
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.
if( zoomedIn == true )
{
GetComponent.orbitOTS.yOffset = Mathf.Lerp( GetComponent.orbitOTS.yOffset, zoom, Time.deltaTime*smooth );
}
else
{
GetComponent.orbitOTS.yOffset = Mathf.Lerp( GetComponent.orbitOTS.yOffset, normal, Time.deltaTime*smooth );
}
}
But, for some reason, I get this error, and I’m not sure how to fix it…
NullReferenceException: Object reference not set to an instance of an object
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.String cacheKeyName, System.Type[ ] cacheKeyTypes, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetDispatcher (System.Object target, System.Object[ ] args, System.String cacheKeyName, Boo.Lang.Runtime.DynamicDispatching.DispatcherFactory factory)
Boo.Lang.Runtime.RuntimeServices.GetProperty (System.Object target, System.String name)
UnityScript.Lang.UnityRuntimeServices.GetProperty (System.Object target, System.String name)
AimYL.Update () (at Assets/AimYL.js:25)
How do I fix this?