hit.point for rayhit not giving me what I'm looking for

I have a camara up high (y=100) looking straight down toward a ground (100x100x5 cube). I’m drawing a visble ray to where I click on the box and the ray shows up just fine (image)

alt text

but no matter where I click I get

(0.0, -5.6, 0.0)
UnityEngine.Debug:Log(Object)
Level:Update() (at Assets/Level.js:26)

Which blows my mind. Here’s the code:

#pragma strict

var ballPrefab:Transform;
private var ball:Transform;
private var lastMousePos:Vector3;

function Start () {
	ball = Instantiate(ballPrefab, 
						transform.Find("ballStartSpawn").transform.position, 
						Quaternion.identity);
}

function Update () {
	var ray:Ray;
	if(lastMousePos != null) {
		ray = Camera.main.ScreenPointToRay(lastMousePos);
		Debug.DrawRay(ray.origin, ray.direction * 130, Color.red);
	}

	if(Input.GetMouseButtonDown(0)){
		lastMousePos = Input.mousePosition;
    	var hit:RaycastHit;
		ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		
		if(Physics.Raycast(ray.origin, -Vector3.up, hit)) {
			Debug.Log(hit.point);
		}
	}
}

I just want to find out where my ray from the camera is touching the pink cubes collider. Should that be hit.point?

if(Input.GetMouseButtonDown(0)){
lastMousePos = Input.mousePosition;
var hit:RaycastHit;
ray = Camera.main.ScreenPointToRay(Input.mousePosition);

if(Physics.Raycast(ray, out hit)) {
Debug.Log(hit.point);
}
}

does this work?

I’ve coded this on the fly and don’t know much of JS

but I’ve been trying to compare my provided C# code and yours

Well, for the debug line you correctly compute the direction as ray.direction * 130, but for the raycast you use -Vector3.up, which is just straight down. The ray.origin is always (mostly) the same - a position very close to your camera (=on near clip plane), so just use ray.direction as direction, or as @sdgd suggested, just use the ray directly.