I’m making an FPS game with a lot of world space UIs. I want to use a crosshair to click buttons or move sliders.
Normally I use Physics.Raycast() to detect game objects in front of my crosshair, but these UIs don’t have colliders, and Physics.Raycast() can’t detect them.
I tried adding box colliders to them, but the boxes don’t automatically fit (very tiny comparing with UI elements ). Very inconvenient.
So is it a good way to interact with word space UIs with Physics.Raycast()? Are there better ways to do this?
This is a bit old, but since I’ve just recently been messing with this stuff myself, I figured I’d drop a couple helpful links to anyone else who comes across this.
This is doable without using physical colliders, but does require messing with the EventSystem itself.
If you want a controllable crosshair you can move around the screen like a mouse cursor, check this first link –