- Home /
Raycasting and receiving hit.colliders with two cameras
Hello,
when I have two cameras, and one is rendering above the other (for a in-game-menue) and from another script I am sending a Raycast, are both cameras involved?
I am sending a Raycast and my menue-camera is not returning anything when I hit a collider.
Which camera is the script attached to and can you paste your code for the raycast call itself?
You should have a $$anonymous$$ain Camera, and you can define that camera as the source of the raycast, but I need to see your code to give you a code example
the code for the raycast itsef is
var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
Physics.Raycast (ray, hit, 100);
okay, I see it, there is "Camera.main.ScreenPointToRay" in it. How do I choose the other camera for raycasting?
So you can set a public variable (editable in the inspector) to store the camera you want to use (like var RayCamera:Camera;) then use that ins$$anonymous$$d of "Camera.main"