I have a question on how to get the position of Raycast.
During my use of handtracking, I want to know the exact position of the raycast when the user trigger the ‘Click’ gesture. Is there any helpful API?
Many thanks~
My current solution is as follows, but it didn’t work as expected. It seems the use of ‘Camera.main.ScreenPointToRay’ is not correct.
public void OnPointerClick(PointerEventData eventData)
{
RaycastHit hit;
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
Physics.Raycast(ray, out hit, 10, 1<<9);
Vector3 localhit = transform.InverseTransformPoint(hit.point);
if (hit.collider != null)
{
Debug.Log(hit.collider.name);
Debug.Log(localhit);
}
else
{
Debug.Log("ERROR");
}
}