Quantcast
Channel: Answers by "chmodseven"
Viewing all articles
Browse latest Browse all 8

Answer by chmodseven

$
0
0
This seems to work well enough for me with a plane and a camera in the variables: Vector3 mousePosition = Input.mousePosition; Ray screenPosition = _cam.ScreenPointToRay (mousePosition); if (!_plane.GetComponent ().Raycast (screenPosition, out RaycastHit hit, 1000)) { return; } Vector3 hitPoint = _cam.WorldToScreenPoint (hit.point); Vector3 planeMin = _cam.WorldToScreenPoint (_plane.GetComponent ().bounds.min); Vector3 planeMax = _cam.WorldToScreenPoint (_plane.GetComponent ().bounds.max); float xProportion = Mathf.InverseLerp (planeMin.x, planeMax.x, hitPoint.x); float yProportion = Mathf.InverseLerp (planeMin.y, planeMax.y, hitPoint.y); float xPoint = xProportion * sourceImage.width; float yPoint = yProportion * sourceImage.height; Vector2 startPosition = new Vector2 (xPoint, yPoint);

Viewing all articles
Browse latest Browse all 8

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>