#I have a game that involves moving a
1 messages · Page 1 of 1 (latest)
I have code running that fires a Ray to determine if the ball's clickable area was clicked.
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if(Physics.Raycast(ray, out hit)) {
if(hit.transform.gameObject == knockerSphere || hit.transform.gameObject == controlSphere) {
dragging = true;
}
}
My feeling is that the Reset button on the screen space overlay canvas should capture the ray instead of my gameobjects
However, it seems that the ray for some reason does not do so and I'm hoping someone might help me figure out how to get Physics.Raycast to say the button is what's hit by the ray rather than my gameobjects
I think I've had this issue too
using a tag maybe
I wanted the UI to block the raycast, and even after setting it how it should be, the ray would still go through
That's a good idea
I did find my answer however here: https://forum.unity.com/threads/physics-raycast-finds-ui-button.741527/