- Home /
Casting a ray when using overlayed cameras (orto and perspt) for GUI and game?
Okay so the basic problem I'm having and i can't seem to google the right answer is this.
Until now i was making GUI by making all of its elements child of MainCamera. It works and im used to it but I wanted to try out the second way to do it thats it with two cameras.
I managed to find out how to set the cameras to display my GUI and the problem is following:
On touch (since this is mobile project) i cast a ray to check if i have hitted a button (button is quad with box collider and a respective tag, example start button is BTNStart) but raycasting doesnt seem to hit any colliders that are in the second camera which handles GUI. I thought that changing the camera to perspective will solve this alas nothing happened. So thats a bump for me. Anyone having any ideas or suggestions?
Thanks in advance
You should enter your 'Edit' as an answer and mark it answered (click on the checkmark).
Answer by MDarkwing · Apr 15, 2014 at 08:19 PM
EDIT: I've finally solved the problem. You need to cast the ray from the camera which you want to hit. Example you have GUI with some quads as buttons and GUICamera that renders them and you want to cast a ray and dettect "button hit" you have to specify that camera when casting ray aka store it in some variable then cast perform a ray cast from it (pseudo code: GUICam.Raycast(...)) Hope this helps some1 out there