使用Physics.OverlapSphere来检测不方便调试, 其他都可以.
核心代码:
//检测敌人 public void CheckEnemy() { Collider[] cols = Physics.OverlapSphere(this.transform.position, attackRange); if (cols.Length > 0) { foreach (var i in cols) { Debug.Log(i.gameObject.tag); if (i.gameObject.CompareTag("Enemy")) { //检测到敌人在主角以attackRange半径的圆里面 } } } }