- Home /
Question by
Shnayzr · Feb 27, 2016 at 09:28 PM ·
collidermousecollider2dmouseclick
how to put a collider on an object but doesnt block the mouse click on the object behind?
I only need the collider to check if other objects entered its region or not, i dont want it to block other gameobjects OnMouseDown() function
any help please
Comment
Best Answer
Answer by Pharaoh_ · Feb 27, 2016 at 09:47 PM
What about setting it to Ignore Raycast layer?
Go to the collider Game Object and on the top right you can see the "Layer" which is set to Default. Use "Ignore Raycast". On $$anonymous$$ouseDown() uses raycasting and a collider is needed. Setting is to this layer, however, will make the method ignore the object.
Answer by SpiderJones · Mar 27, 2021 at 01:24 AM
Hi, you can do this...
[SerializeField] private LayerMask inputLayerMask;
private void Start()
{
Camera.main.eventMask = inputLayerMask;
}
Then in the game object's inspector set what layer mask, or masks, you want to receive mouse input.