- Home /
2D - Overlaying Colliders - MouseDown not detected
Hi there,
I got a background element with a boxcollider2d and a an object (boxcollider2d) overlaying that background element.
Now I tried to raycast the object to click and I tried it with OnMouseDown(). When I move the object to an area where no collider is in the back everything works like a charm.
So why am I getting the Object in the back instead of the object in the front?
I also tried to adjust the z-value and I tried to use different sorting layers...no chance... When I use two different collider (boxCollider2d for the background and circlecollider2d for the overlaying element) it also won't work.
Any idea?
Stupid me! I got my camera on z=-10. I adjusted everything. I set the clickable object on -3 and the other objects on -1. Now it works...
Your answer
Follow this Question
Related Questions
Mouse clicking on an object (Raycast.hit) for another object to connect to it? 0 Answers
Raycast Collider Tag not returning correct result 1 Answer
Detect OnMouseUp on gameobject with different colliders 1 Answer
RaycastHit2D hits "itself" 3 Answers
How to make the player jump down from the platform 0 Answers