「B」というタグがついたCubeが「A」というタグのついたCubeに衝突したとき、所定の位置にUIを生成させようとしたのですが、なぜか見当違いな位置に生成されてしまいます。そして、UIの大きさも違く、欲しいのは一つだけなのに、四つも生成されています。エラーなどは出ていません。画像のようになっています。
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4 5public class B_keiyu : MonoBehaviour { 6 7 public GameObject A; 8 public GameObject A2; 9 public GameObject B; 10 11 public GameObject canvasObject; 12 13 public GameObject Panel; 14 15 //public GameObject Forward; 16 17 18 // Use this for initialization 19 void Start() 20 { 21 22 } 23 24 // Update is called once per frame 25 void Update() 26 { 27 28 } 29 30 private void OnTriggerEnter(Collider other) 31 { 32 if (other.gameObject.tag == "A") 33 { 34 B.transform.position = A.transform.position; 35 GameObject prefab = (GameObject)Instantiate(B,Panel.transform.position, Quaternion.identity); 36 prefab.transform.SetParent(canvasObject.transform, false); 37 38 } 39 if (other.gameObject.tag == "A2") 40 { 41 B.transform.position = A2.transform.position; 42 } 43 } 44 45 46}
どうすれば解決出来るでしょうか?uGUIなのでローカル座標を指定する必要があるのでしょうか?回答よろしくお願いします。
※捕捉
四つ生成されるのは、Box Colliderが複数ついていたためでした。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。