切換
舊版
前往
大廳
主題

(筆記) CompareApproximately (det, 1.0F, .005f)

浪濤書記 | 2016-11-30 01:19:34 | 巴幣 0 | 人氣 190


↓伴隨著下面這個錯誤訊息出現
「Nullreferenceexception object reference not set to an instance of an object」

●原本:
void OnTriggerEnter(Collider other)
{
       //程式內容;
}

●改成(※即增加對觸碰物的判定):
void OnTriggerEnter(Collider other)
{
       if (other.gameObject.tag == "Bullet")
       {
              //程式內容;
       }
}


#狀況2:
void OnTriggerEnter(Collider other)
{
        if (other.gameObject.tag == "Bullet")
        {
             (略).. =other.gameObject.GetComponent< Damage >().AttackPower;
        }
}
但是碰到的物體上並沒有套用< Damage >這個程式碼,
或者< Damage >根本沒有AttackPower這變數,補上便解決了。

送禮物贊助創作者 !
0
留言

創作回應

更多創作