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);
transform.position.y=MuCursor.y;
}