private void OnCollisionEnter(Collision other) { if (other.gameObject.CompareTag("agent") && m_State == false) { myButton.GetComponent <Renderer>().material = onMaterial; m_State = true; m_AreaComponent.CreatePyramid(1, m_PyramidIndex); tag = "switchOn"; } }
// 與其他物件產生碰撞 void OnCollisionEnter(Collision other) { // 若產生碰撞的對象是agent,而且m_State是false(已經重新設置過按鈕) if (other.gameObject.CompareTag("agent") && m_State == false) { myButton.GetComponent <Renderer>().material = onMaterial; //按鈕顏色為綠色 m_State = true; m_AreaComponent.CreatePyramid(1, m_PyramidIndex); // 建立一個新的目標金字塔 tag = "switchOn"; } }