- Home /
Is Raycast relatived to screen resolution?
hi, I use Physics.Raycast(overray, out overhit, 80f) to select a gameobject. It works fine when the screen resolution is 1366*768, but when I change resolution to 1024*768 or connected to the projector, it doesn't work. Can anybody tell me why and how to solve this? Thanks!
Answer by khenkel · Sep 30, 2014 at 12:23 PM
Simple answer: Physics.Raycast() ITSELF is NOT related to the screen resolution.
Better answer: Your problem is probably related to your "overray" Ray object (eg. when you're creating it via "Camera.ScreenPointToRay()"). Please provide the specific part of your code so we're able figure out what the problem is.
There is only one "$$anonymous$$ain Camera" in the scene.
GameObject cam$$anonymous$$ainObj = GameObject.Find ("$$anonymous$$ain Camera");
cam$$anonymous$$ain = cam$$anonymous$$ainObj.GetComponent<Camera>() as Camera;
Ray overray =cam$$anonymous$$ain.ScreenPointToRay(Input.mousePosition);
RaycastHit overhit = new RaycastHit();
Physics.Raycast(overray, out overhit, 50f )
What is the difference between cam$$anonymous$$ain and Camera.main?
Your answer
Follow this Question
Related Questions
Calculate where an object is going to land 0 Answers
How to get distances of GameObjects through SphereCast? 1 Answer
Raycast stop at distance 3 Answers
Is there a limit on the distance of raycast? 2 Answers
Skateboard slope problem 0 Answers