예제 #1
0
 private void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Trash")
     {
         if (col.gameObject)
         {
             Tscript = col.gameObject.GetComponent <TrashMove>();
             Tscript.TrashChangeY(0);    //Y軸の上昇値を0に設定
             Vector3 pos = col.gameObject.transform.position;
             col.gameObject.transform.position = new Vector3(pos.x, TrashSpawner.CopyPosY + 2.1f, pos.z);
             Destroy(col.gameObject.GetComponent <TrashPosFixation>());
         }
         else
         {
             Debug.Log("GameObjectは消去されました");
         }
     }
     if (col.gameObject.tag == "Plastic_cup")
     {
         Tscript = col.gameObject.GetComponent <TrashMove>();
         Tscript.TrashChangeY(0);    //Y軸の上昇値を0に設定
         Vector3 pos = col.gameObject.transform.position;
         col.gameObject.transform.position = new Vector3(pos.x, TrashSpawner.CopyPosY + 1.9f, pos.z);
         Destroy(col.gameObject.GetComponent <TrashPosFixation>());
     }
     if (col.gameObject.tag == "PlasticBag")  //ゴミの横移動停止
     {
         Vector3 pos = col.gameObject.transform.position;
         col.gameObject.transform.position = new Vector3(pos.x, TrashSpawner.CopyPosY + 1.8f, pos.z);
     }
 }
 private void OnCollisionExit(Collision col)
 {
     if (col.gameObject.tag == "Trash" || col.gameObject.tag == "Plastic_cup")
     {
         script = this.gameObject.GetComponent <TrashMove>();
         script.TrashChangeY(-0.00001f);
         Vector3 pos = this.gameObject.transform.position;
         this.gameObject.transform.position = new Vector3(pos.x + randomX * 2, TrashSpawner.CopyPosY, pos.z + randomZ);
         Stop();
         count = 0;
         Debug.Log("objectが離れました");
     }
 }
 private void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Trash" || col.gameObject.tag == "Plastic_cup")
     {
         Debug.Log("ゴミが触れたので位置を調整しました");
         script = this.gameObject.GetComponent <TrashMove>();
         script.TrashChangeY(-0.00001f);
         randomX = Random.Range(0, 3);
         randomZ = Random.Range(0, 4);
         Vector3 pos = this.gameObject.transform.position;
         this.gameObject.transform.position = new Vector3(pos.x + randomX * 2, TrashSpawner.CopyPosY, pos.z + randomZ);
         Stop();
         count++;
         //Debug.Log(count);
     }
 }
예제 #4
0
 private void OnTriggerEnter(Collider col)
 {
     if (col.gameObject.tag == "Trash" || col.gameObject.tag == "Plastic_cup")   //Trashに触れたら指定ポイントに再設置しY軸上昇
     {
         Tscript = col.gameObject.GetComponent <TrashMove>();
         Tscript.TrashChangeY(0.008f);
         Vector3 pos = col.gameObject.transform.position;
         col.gameObject.transform.position = new Vector3(pos.x, TrashSpawner.CopyPosY + 1.6f, pos.z); //2.1
     }
     if (col.gameObject.tag == "PlasticBag")                                                          //PlasticBagに触れたらY軸固定
     {
         Pscript = col.gameObject.GetComponent <PlasticBagMove>();
         Pscript.PlasticBagChangeX(0);
         Vector3 pos = col.gameObject.transform.position;
         col.gameObject.transform.position = new Vector3(pos.x, TrashSpawner.CopyPosY + 1.7f, pos.z);
     }
 }