- Home /
Mouse Click Dead Zone at Center of Camera View
I've made a series of buttons (objects with functions triggered through OnMouseDown which exist in the scene) for my game which are oriented at the center of the screen. This is a strange place for buttons, but the game takes place around the edges. I've noticed that all of the buttons work fine unless they are oriented at the center of the screen, as defined by the camera. Any button within a small radius from center screen does not respond to OnMouseDown. Move the button anywhere else and it works. Move the camera to where the center is different and whatever button falls under the new center will stop working.
I should expand this explanation to include that I am using Unity 3.5.1 on Win7 64-bit, and that OnMouseOver also doesn't work in the dead zone, which is how I first noticed it.
Really, this is just so weird that I can't reasonably expect a solution (though I'd be thrilled if there was one since this is such a nasty break in my game design), I'm just curious as to whether anyone else has experienced this.
Going to go redesign my button layout now. Good buy, two days of work!
UPDATE : I saved my layout! Apparently this only happens when the clickable object is greater than 40 units from the camera. I wont even question that, I'm just happy it works now.
UPDATE : I was unable to reproduce this effect in a newly made project, so I'm assuming that it was some strange combination of the way I did things in the previous one which caused the issue. A further reminder that making games is the most challenging game of them all!
-BroB
Answer by gregzo · Apr 14, 2012 at 11:29 PM
OnMouseDown does a Raycast for you automaticaly. The only thing I can think of is maybe you're using a character controller that interferes with it? From the docs:
Note: This function will return false if you cast a ray from inside a sphere to the outside; this in an intended behaviour.
There is no character controller, it's a board game. The camera is free floating in empty space.
Hmmm, did you try a quick test, empty scene, cube in the "dead zone", simple debug?
Not yet. This project is almost done with a deadline of a few days from now. I found a workaround that works, so unless it rears its ugly head again in a new way, more thorough testing will have to wait. For now it seems having the object closer than 40 units from the camera fixes it, and the stress relief that came with finding that out was overwhel$$anonymous$$g. As soon as I have the time, I will build a scene specifically to measure the exact radius of the dead zone, if it carries over.
Answer by meslin · May 01, 2012 at 07:16 PM
I have been having similar experiences with a dead zones using an OnMouseDown function. Could not find anything in the way, and tried moving the camera and object around....ended up just manually raycasting instead. I have an inkling of a suspicion that there is a real problem going on. No idea.
Your answer
![](https://koobas.hobune.stream/wayback/20220613070333im_/https://answers.unity.com/themes/thub/images/avi.jpg)