Is it possible to exclude a GameObject by his tag for a Physics2D.OverlapPoint test ?,
hi, i wonder if it's possible to exclude a GameObject
and by extension all the GameObject
s with the same tag when i use Physics2D.OverlapPoint
with a specific Layer
ex:
void ChechCollider()
{
listObjectA = GameObject.FindGameObjectsWithTag("objectA");
LayerMask collisionObjectGroups = (1 << 14);
Vector2 objectAPos;
Collider2D collisionWithObjects;
foreach (GameObject objecta in listObjectA)
{
objectAPos = objecta.GetComponent<ObjectA>().GetPosition;
collisionWithObjects = Physics2D.OverlapPoint(objectAPos, collisionObjectGroups);
if(collisionObjectGroups.tag != "objectAClone")
{
//do something
}
}
}
if i have multiple different GameObject
s in the layer 14
, including objectAClone
, how can i exclude objectAClone
from the test ?
If i understand the doc well, Physics2D.OverlapPoint
stop at the first overlapping. So when i make my test, if the first overlapping is with a objectAClone
, it stop checking. Even if objectA
position overlap with others GameObject
s in the layer 14
.
But with the code i made, it doesn't work.
Does anyone have an idea ?
Thanks for your time and sorry if i made mistakes in my question, its the first time for me.
Your answer
Follow this Question
Related Questions
Trouble with Physics2D.OverlapArea detection 2 Answers
,How to use Physics2D.OverlapArea 1 Answer
Getting the correct angle for OverLapBoxAll 1 Answer
Unity Overlap Point Causing Error 0 Answers
OverlapBoxAll rotation 2 Answers