simple raycast telling distance from ground

I have never really used a raycast for anything. I usually just work around it because every time I’ve used it I would get errors of some sort. But basically I would like a ray cast that just tells my controller it’s distances from the ground. I also would like to have more info on raycast. A link or something. I’m also working in c#

You want to make fast friends with Raycast, it is the perfect tool for many things.

	Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

	Physics.Raycast (ray, out hit)

if the ray hit something, the something will be assigned to hit.
hit. (exposes the gameObject’s hierarchy, ie. hit.transform. hit.gameObject.Getcomponent, hit.tag, etc.)

Here’s the sample code from that page

function Update () {
	var hit : RaycastHit;
	if (Physics.Raycast (transform.position, -Vector3.up, hit)) {
		var distanceToGround = hit.distance;