- Home /
OnMouseDown not firing if character isn't touching ground
I am trying to use "OnMouseDown" on one of my NavMeshAgents. I set it up so the collider that's on the character won't interact with the floor (otherwise I have bugs with my navigation), but now "OnMouseDown" doesn't work anymore. If I re-enable the collider but make it so it doesn't actually touch the floor (it is smaller so it doesn't reach the character feet) "OnMouseDown" still doesn't fire! Only if the collider touches the ground Unity realises that I am clicking the character.
This behavior is strange, to say the least. How can I make it so "OnMouseDown" works without forcing the character to physically interact with my environment?
On$$anonymous$$ouseDown requires both a non-trigger collider and a line of sight. It might be that when the character doesn't touch the floor, something else is blocking the view? Try putting every other object with colliders inside the IgnoreRaycast layer.