Hey there,
I have two C# scripts; one is a throttle lever (throttlelever.cs) that when clicked, should be triggering an iTween animation; the object to activate being given (caraccelerate.cs).
My error is
NullReferenceException: Object reference not set to an instance of an object
throttlehover.OnMouseDown () (at Assets/throttlehover.cs:17)
UnityEngine.SendMouseEvents:DoSendMouseEvents()
I’m Guessing they can’t find one another, but I hope someone will be able to enlighten me on why that is.
My throttle script:
using UnityEngine;
using System.Collections;
public class throttlehover : MonoBehaviour
{
public caraccelerate accelerate;
void OnMouseEnter ()
{
renderer.material.color = Color.red;
}
void OnMouseExit ()
{
renderer.material.color = Color.white;
}
void OnMouseDown ()
{
accelerate.OnAccelerate();
}
}
My caraccelerate vehicle script:
using UnityEngine;
using System.Collections;
public class caraccelerate : MonoBehaviour
{
public void OnAccelerate ()
{
iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("centralline"), "time", 50, "easetype", iTween.EaseType.easeInOutSine));
}
}
Kind regards,