球形检测

xiaoxiao2025-05-29  14

分享一个十分基础的物理检测模式

具体代码如下:

   //球形检测

           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;

                }

           }     

     }

路过的大神不要笑话我写的简单

同理盒型检测写法大致相同 

转载请注明原文地址: https://www.6miu.com/read-5030928.html

最新回复(0)