Open1

[Unity] Physics.OverlapSphereNonAlloc当たり判定

gonCgonC
Search
public class Search : MonoBehaviour
{
  private Collider[] searchCol = new Collider[1];
  private void FindTargetPlayer()
  {
    int layerMask = LayerMask.GetMask(new string[] { "hogehoge", "fugafuga"});
    var num = Physics.OverlapSphereNonAlloc(gameObject.transform.position, 3f, searchCol, layerMask);
    if (num >= 1)
    {
			    var targetPlayerTran = searchCol[i].gameObject.transform;
    }
  }
}