Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

Raycast misses after camera zoom

$
0
0
Hi there, I have two cameras in my game scene, the main camera and the HUD camera, both orthographic. The HUD camera shows the scores and pause button and the main camera shows the other game objects. When the game is about to finish, the scene will be zoomed out by increasing the "size" of the main camera. That's when the problem happens. After the game is done, a menu with "restart" and "home" button will pop up in the HUD camera. if(Application.platform==RuntimePlatform.OSXEditor){ if(Input.GetMouseButtonDown(0)){ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if(Physics.Raycast (ray,out hit)){ if(hit.collider.tag == "Restart"){ Application.LoadLevel("PlayScene"); } else if(hit.collider.tag == "Home"){ Application.LoadLevel("HomeScene"); } } } } The buttons cannot be pressed when the main camera is zoomed out. Is it because of the position of the buttons has changed according to the main camera? Can anyone suggest how I can solve this problem?

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>