OnMouseDown() unreliable

Hi,
I’m building a house with several items “hidden” in other objects like drawers.
So a user clicks a drawer, it translates open, then the object in side it visible and the user can take it.
However I am having issues with some objects.
In the screen shot you can see an open drawer with an iPod inside. The drawer only has a Collider on the front. As far as I can see there are no colliders interfering with the collider of the iPod.
I’ve scaled the colliders up a little to make them easier to click on.
I’ve set up a simple script attached to the iPod:

void OnMouseDown(){
		if ( Vector3.Distance( transform.position, Player.transform.position ) < distance ){
			print"object close enough and clicked. do something";
		}
	}

Now what happens is:
When I stand (FPC) stand say 1.5m away and I click the drawer, it opens and I can take the iPod without any problem.
When I however stand as close to the drawer as I can, I suddenly can’t click on the iPod anymore. The click is not registered.

Also, I can only click on the “front” side of the collider of the drawer. When I stand close to the iPod I should be able to click on the top or back of the drawer collider but that does not register either.

I can click on a tiny area just below (in the image) the iPod and the drawer, but that’s all.

I do have a Screen.CursorLock = false; Screen.CursorLock = true; in Update() in a script attached to the FPC. When I disable that, I am able to click correctly.
It seems as though the Lockcursor does something to the coordinates?

What am I missing?


Thanks!!

Marco

Seems I’ve found the issue. Really a bit of silly.
I’ve changed the maximum look-down angle on the FPC camera to 80 degrees, so you can look down a lot more that with the default parameters.
But as the FPC camera is positioned in the middle of the FPC collider and the field of view of the camera is 60 degrees, the visible area actually overlaps the FPC collider for a significant part. So with a locked mouse in the middle of the screen and looking down, you actually are clicking on the FPC collider instead of the collider of the object you hope to click on!
I just moved the camera a little forward and that solved those problems. It does of course increase the risk of ending up inside a wall or such.