Following the cursor...

Hello. I want an object in my game to follow the player’s mouse cursor y position (regardless of whether they are holding down the mouse buttons or not). I think I know what I have to do (construct a ray from the cursor to a collider, convert that to world space, and then set the object’s transform.position.y equal to that number)…I just cannot figure out how to do it.
I have the ray part of the script, but how do I convert it to a Vector3 (I am guessing it has something to do with this, I just do not know how to implement it). Thanks.

var MyCursor : Vector3;    
function Update(){
	var ray : Ray = Camera.main.ScreenPointToRay (Input.mousePosition);

If you know the distance form the camera you want to place the object, then Camera.ScreenToWorldPoint() is a nice solution.

function Update() {
    var pos = Input.mousePosition;
    pos.z = distance_to_object;
    transform.position = Camera.main.ScreenToWorldPoint(pos);

Check my answer here : Attach 3D object to mouse - Questions & Answers - Unity Discussions