Set alpha cutoff value Unity3d

I am continuing my previous question( link ). Now its working as per this demo.

and the coding written to set cutoff is here :

function Update () {

renderer.material.SetFloat("_Cutoff", Mathf.InverseLerp(0, Screen.width, Input.mousePosition.x));

}


But i want to set cutoff value , depending up on distance between two object.

one object position will be static. and i am moving another object and if my object gets far distance then cutoff should be 0. and if the object gets closer then depending up on the distance between these two object , i want to set cutoff value.

so how do i set cutoff value?

// Distance: length of vector (static - moving).