タイトルの通りですが、
下画像のようにarrowとwallが重なっていて両方にBoxCollider2Dがアタッチされています。
この状態でUpdate()内でIsTouchがtrueが返ると思っていたのですがfalseしか返ってきません。
なぜでしょうか?
c#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using UnityEngine.UI; 5using UnityEngine.EventSystems; 6using System; 7 8public class TestScript : MonoBehaviour { 9 10 private GameObject mArrow; 11 private GameObject mWall; 12 13 void Start () { 14 mArrow = GameObject.Find("arrow"); 15 mWall = GameObject.Find("wall"); 16 } 17 18 void Update () { 19 BoxCollider2D arrowBoxCollider = mArrow.GetComponent<BoxCollider2D>(); 20 BoxCollider2D wallBoxCollider = mWall.GetComponent<BoxCollider2D>(); 21 22 Log.d("IsTouching", arrowBoxCollider.IsTouching(wallBoxCollider).ToString()); 23 } 24 25 26} 27
◆環境
Unity2017 3.1f1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/31 06:43
退会済みユーザー
2019/03/31 06:49
2019/03/31 06:52