how can i Find an object height, while click on that object?

Hi All,

In a scene i have 3 different objects.
my task is if i click an object i just want to print the height of an object.

i wrote code like this:

  var point: Vector3;
  var duration: float;
  var object: GameObject;
  private var startTime: float = 0;

   function Update(){
if (Input.GetMouseButtonDown(0)){
    var hit: RaycastHit;
    var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
    if (Physics.Raycast(ray, hit)){
        startTime = Time.time;
        point = hit.point;
        object = hit.transform.gameObject;

After saving it is shows there is no errors but when ever i am clicking the gameobject that is showing an exception.

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)
NewBehaviourScript.Update () (at Assets/NewBehaviourScript.js:17)

Can i get any help

Thanks in advance


Avoid using reserved keyword, I would think object is reserved and you are doing somehtin wrong with it.

Try using obj instead

and try

obj = hit.collider.gameObject;

still, avoid object.