- Home /
Physics2D.OverlapBoxNonAlloc not return all overlapped collider
Hello, I have a problem with the method Physics2D.OverlapBoxNonAlloc. Actually I used the command like this: int num = Physics2D.OverlapBoxNonAlloc(Position, new Vector2(Width, Height), 0, collider2Ds); where collider2Ds is an array previosly allocated. In a overlap situazione like this, where box is egual to the position and dimension of box 2, the only collider returned in the previous array is the collider 2 and not also the collider 1.
At first you need to make sure your "collider2Ds" array is big enough to receive all the expected results. In my case, my enemy can only detect at most 3 players, so that's the size I use and it works fine.
Answer by underhand · Oct 19, 2019 at 07:20 AM
Yes, I confirm that the array is big enough, because, in this case, I have only three colliders (the third is not showed in the image) and the array is allocated in order to receive three colliders.
Your answer
Follow this Question
Related Questions
Multiple Collider of Platform Effector overlap Problem 1 Answer
Checking for Colliders with Physics2D.OverlapBoxAll Won't Work? 0 Answers
overlayCircle not working 1 Answer
How to Detect if a Collider is in the Area, Move Away, Rinse and Repeat? 1 Answer
Physics2D.OverlapCircleAll and OverlapCapsuleAll behaves differently? 0 Answers