What’s the best way to have screen-space UI elements block raycasts to the 3D game world?
E.g.
I am using a 3D camera and rigidbody.raycastFirst() to detect interactions with 3D objects in the scene.
I have a game HUD that uses this.entity.element.on(“click”, this._someClickMethod, this); to detect clicks on the UI elements/buttons.
However, the player is able to trigger both at the same time if the HUD element and 3D element overlap each other.
I need a way for the UI to block physics raycasts I guess?
Thank you for the response. Unfortunately, this is on mobile, so there is no hover recognition.
Best I can think of is that on the touch input being received to simply return and do nothing should it be within certain bounding boxes. However, this would be a hacky solution and wouldn’t be too accurate.
Would be surprised if no-one has faced this issue before: it’s a very common thing to need have an interactive UI in a 3D game…