- Home /
How Physics2D.OverlapCircleAll works???
here is my IsGrounded method,,,,
bool IsGround(){<br>
if (rigidBody.velocity.y <= 0) {<br>
foreach(Transform points in groundPoints){<br>
Collider2D[] colliders = Physics2D.OverlapCircleAll (points.position,0.2f);<br>
for(int i=0;i<colliders.Length;i++){<br>
if (colliders [i].gameObject != gameObject) {<br>
return true;<br>
}<br>
}<br>
}
}<br>
return false;<br>
}
what does this part do?? if (colliders [i].gameObject != gameObject) {
return true;
}
Answer by MrAkroMenToS · Apr 24, 2016 at 10:15 AM
Hi @EhsanEhrari
Physics2D.OverlapCircleAll works like Physics.OverlapSphere. It return ALL of the colliders2d in the given radius (in your case 0.2f).
Your IsGround method return true if there at least one gameobject other than the one the script is on.
Your answer
![](https://koobas.hobune.stream/wayback/20220612075508im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
My Rope 2D System behaves abnormally 2 Answers
How to avoid Rigidbody collider from getting stuck between walls 1 Answer
Rigidbody2D.addforce giving jerky movevent 0 Answers
Is calling OnCollisionEnter2D on allot of GameObjects bad for performance? 2 Answers
Problem with 2D collision detection (Wide object falls through a thin hole) 1 Answer