分享一个十分基础的物理检测模式
具体代码如下:
//球形检测
if (aa.isDie == false) {
Collider[] allPlayer = Physics.OverlapSphere (this.transform.position, 3, canHitlayer);
if (allPlayer.Length != 0) {
tempTime += Time.deltaTime;
if (tempTime >= 1) {
allPlayer [0].GetComponent<PlayerHealty> ().BeHit (attack);
tempTime -= 1;
}
} else {
tempTime = 1;
}
}
}
路过的大神不要笑话我写的简单
同理盒型检测写法大致相同