- Home /
Have both overlapping colliders be triggered by OnMouseUp()
I am making a 2d chess game and have two layers. One layer contains the pieces which, when clicked, selects that piece for moving and another later containing the squares for the board which, when clicked, moves the selected piece to that square if it is able to. However, this was working really inconsistently so I used some Debug.Log() to find that the reason is that it is only selecting either the piece or the square, presumably because overlapping colliders only selects one. It would be useful if I could have both colliders activate OnMouseUp(). Is this possible?
Answer by Patrickmol · Jun 14, 2021 at 11:21 AM
Use instead Physics2D.OverlapCircleAll metod... it gets All the colliders in a layer specified or even all of every layer... go on the unity documentation
https://docs.unity3d.com/ScriptReference/Physics2D.OverlapCircleAll.html
Your answer
Follow this Question
Related Questions
Colliders 2d apparently touch each other even if they should not. 2 Answers
2d collision detection 0 Answers
Moving an object with a collider in 2d? 1 Answer
Do I really have to do this? 2 Answers
How to detect multiple Colliders in the same object? 2 Answers