Example #1
0
 //衝突判定
 void OnCollisionEnter(Collision col)
 {
     //壁に当たった時1つ前の位置に戻る
     if (col.gameObject.tag == "Wall" || col.gameObject.tag == "Door")
     {
         Back(last_position);
     }
     //アイテム:鍵Aをゲット
     if (col.gameObject.tag == "ItemKeyA")
     {
         player_state.SetKeyState("KeyA", true);
         Destroy(col.gameObject);
     }
     //アイテム:鍵Bをゲット
     if (col.gameObject.tag == "ItemKeyB")
     {
         player_state.SetKeyState("KeyB", true);
         Destroy(col.gameObject);
     }
     //敵との衝突:ダメージを受ける
     if (col.gameObject.tag == "Enemy")
     {
         player_state.DamagingToPlayer(1);
     }
     if (col.gameObject.tag == "Goal")
     {
         SceneManager.LoadScene("ClearScene");
     }
 }
Example #2
0
 void OnCollisionStay(Collision col)
 {
     //Debug.Log(col.gameObject.tag);
     for (int i = 0; i < key.Length; i++)
     {
         if (col.gameObject.tag == key[i])
         {
             key_flg[i] = true;
             player_status.SetKeyState(key[i], false);
             Instantiate(open_box, transform.position, Quaternion.identity);
             Destroy(col.gameObject);
         }
     }
 }