Get GUITexture to follow ScreenPointToRay ray cast

I have a GUItexture that I would like to follow a raycast.

Current Setup:

		Vector3 Finger = GetWorldPos(fingerPos);
		float Finger_x = Finger.x / Screen.width;
		float Finger_y = Finger.y / Screen.height;
		float Finger_z = Finger.z;
		GameObject.Find("TestingFinger").transform.position = new Vector3(Finger_x,Finger_y,0);

		/* GetWorldPos function is as follows:
		public static Vector3 GetWorldPos( Vector2 screenPos )
		   Ray ray = Camera.main.ScreenPointToRay( screenPos );

		   // we solve for intersection with z = 0 plane
		   float t = -ray.origin.z / ray.direction.z;
		   return ray.GetPoint( t );

However I am getting odd results. (0,0) is the bottom left of the screen and (1,1) is the top right of the screen.

When my mouse/finger is at (0,0) the Guitexture is at (1,1) I think the issue could be that the raycast is returning (0,0) as the middle of the screen. Any ideas how to convert this so the GUItexture will follow the mouse. I have a video of how it is acting “odd” here:


Won’t the final position of the GUITex be just under your finger? Going from finger to world, then back to screen – won’t that just take you back where your finger was? If not, where? Could just do that with: Finger_X=Input.mousePosition.x/Screen.width; and get rid of the ray.

Say you wanted the GUIText to be centered over the object your finger is touching, then you’d need it all – ray cast, take pos = HIT.transform.position, and back to the screen with Camera.main.worldToViewPort(pos).

But, in what you have, GetWorldPos is returning ray.GetPoint(), which is a spot in the game world, in meters. Then it gets used as pixels. In general that will give random results (based on camera pos.)