Subtracting rays

I am trying to subtract two ray values from each other in order to determine the change in distance factor. Ideally i would like to subtract my ray distance from last update cycle, from my ray distance on this update cycle, thus obtaining a number. This will be used to determine the rate of climb for my aircraft. this is the code I have come up with:
var timerdistance:float;

timerdistance += Time.deltaTime;
	var groundHit : RaycastHit;	
	Physics.Raycast( rigidbody.transform.position - Vector3.up, -Vector3.up, groundHit );
	if (timerdistance > 1){
	var groundHit1 : RaycastHit;
	Physics.Raycast( rigidbody.transform.position - Vector3.up, -Vector3.up, groundHit1 );
	timerdistance = 0;
	groundDisplay.text = Mathf.Round( groundHit.distance - groundHit1.distance ) + "m";

I am not getting the right result. please help. Thanks.

If I understand what is going on here correctly, you should be getting zero. That is, your first Raycast() happens every frame. Your second only happens once a second, but it happens is the same frame as your first, so it will be zero the first frame, and then it will change as groundHit1 becomes stale, then it will zero again the next time groundHit1 is calculated.

Plus, if your terrain is not flat and if you ironed out the issues with this code, the rate of climb would still be wrong. For example, if the plane is flying level and the ground rose up, then the indicator would indicate a descending plane. It seems to be you just want to report the change in ‘Y’ position over time to get the rate of climb.

Whatever method you select, I suggest you use InvokeRepeating() as some frequency (0.25 seconds to 1.0 seconds depending on how frequently you want the display to update), and report the difference between the current reading and the previous reading.

I forgot about change in terrain! You are right this method will not work. I may have to go to a y velocity.magnitude model. Thanks, I was so busy over thinking I missed the obvious!