How to use Physics2D .OverlapBoxNonAlloc <problem>

Howdy!,I have a problem here…
I have a problem here…
I use OverlapBoxNonAlloc to search for players and let him run back(result).
But I am not quite sure how he works and why does he not work?

public Vector2 detectRange = new Vector2(15,10) ;

public void SearchPlayer(){
Collider2D hits = new Collider2D[1] ;
int result = Physics2D.OverlapBoxNonAlloc(transform.position, detectRange, 0, hits, 1<<9) ;
if(result > 0){
target = Game.player() ; //Get player “Tag” via Static Class Data
StopCoroutine(“SearchTimer”) ; //execute program
}
}

He doesn’t search…so that my AI can’t find players and track
Or I am missing some settings

Known possible problems:
layerMask
orientation

This topic was automatically closed after 166 days. New replies are no longer allowed.