回答編集履歴

2

誤字の修正

2016/12/03 05:19

投稿

退会済みユーザー
test CHANGED
@@ -62,7 +62,7 @@
62
62
 
63
63
  RaycastHit hit;
64
64
 
65
- if (Physics.Raycast(transform.position, Vector3.forward, out hit, lmMap)){
65
+ if (Physics.Raycast(origin, Vector3.forward, out hit, lmMap)){
66
66
 
67
67
  // 何らかの処理
68
68
 

1

情報の追加

2016/12/03 05:19

投稿

退会済みユーザー
test CHANGED
@@ -47,3 +47,35 @@
47
47
  [スクリプトリファレンス: Physics2D.OverlapPoint](https://docs.unity3d.com/ja/current/ScriptReference/Physics2D.OverlapPoint.html)
48
48
 
49
49
  [スクリプトリファレンス: LayerMask](https://docs.unity3d.com/ja/current/ScriptReference/LayerMask.html)
50
+
51
+
52
+
53
+
54
+
55
+ 3Dの場合
56
+
57
+ ```C#
58
+
59
+ void MapRaycast(int x, int y){
60
+
61
+ Vector3 origin = new Vector3(x,y,0f);
62
+
63
+ RaycastHit hit;
64
+
65
+ if (Physics.Raycast(transform.position, Vector3.forward, out hit, lmMap)){
66
+
67
+ // 何らかの処理
68
+
69
+ // hit.collider.GetComponent<TestScript>().ChangeColor();
70
+
71
+ }else{
72
+
73
+ // 何もない
74
+
75
+ }
76
+
77
+ }
78
+
79
+ ```
80
+
81
+ [スクリプトリファレンス: Physics.Raycast](https://docs.unity3d.com/ja/current/ScriptReference/Physics.Raycast.html)