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: http://db.tt/c2H55tO8
Thanks.