回答編集履歴

4

インデント修正

2019/12/29 12:06

投稿

madone99
madone99

スコア1855

test CHANGED
@@ -10,19 +10,19 @@
10
10
 
11
11
  Ray ray = new Ray(transform.position, transform.forward);
12
12
 
13
- Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
13
+ Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
14
14
 
15
- RaycastHit hit;
15
+ RaycastHit hit;
16
16
 
17
- if (Physics.Raycast(ray, out hit, 50.0f) {
17
+ if (Physics.Raycast(ray, out hit, 50.0f) {
18
18
 
19
- if(hit.collider.gameObject.compareTag(“トンカチ”) ) {
19
+ if(hit.collider.gameObject.compareTag(“トンカチ”) ) {
20
20
 
21
- 壊れた壁.SetActive(true);
21
+ 壊れた壁.SetActive(true);
22
22
 
23
- }
23
+ }
24
24
 
25
-        }
25
+ }
26
26
 
27
27
 
28
28
 

3

修正

2019/12/29 12:06

投稿

madone99
madone99

スコア1855

test CHANGED
@@ -1,3 +1,5 @@
1
+ 変数名は疑似コードとして、
2
+
1
3
  Physics.Raycastで検索するとブログなどが出てくるので、どういう風に使うか読んでみてください。
2
4
 
3
5
 
@@ -16,7 +18,7 @@
16
18
 
17
19
  if(hit.collider.gameObject.compareTag(“トンカチ”) ) {
18
20
 
19
- # 使っ時の処理
21
+ 壊れ壁.SetActive(true);
20
22
 
21
23
  }
22
24
 

2

修正

2019/12/29 11:19

投稿

madone99
madone99

スコア1855

test CHANGED
@@ -14,7 +14,7 @@
14
14
 
15
15
  if (Physics.Raycast(ray, out hit, 50.0f) {
16
16
 
17
- if(hit.collider.gameObject.compareTag(“アイテム”) ) {
17
+ if(hit.collider.gameObject.compareTag(“トンカチ”) ) {
18
18
 
19
19
  # 使った時の処理
20
20
 

1

Physics.Raycastを使用する修正

2019/12/29 11:01

投稿

madone99
madone99

スコア1855

test CHANGED
@@ -1,14 +1,8 @@
1
- 以下の部分(と対応するとじかっこ「}」を削除すれば
2
-
3
- 実行されませんか?
4
-
5
-
6
-
7
1
  Physics.Raycastで検索するとブログなどが出てくるので、どういう風に使うか読んでみてください。
8
2
 
9
3
 
10
4
 
11
-
5
+ ## 変更
12
6
 
13
7
  ```C#
14
8
 
@@ -18,8 +12,16 @@
18
12
 
19
13
  RaycastHit hit;
20
14
 
21
- if (Physics.Raycast(ray, out hit, 50.0f))
15
+ if (Physics.Raycast(ray, out hit, 50.0f) {
22
16
 
17
+ if(hit.collider.gameObject.compareTag(“アイテム”) ) {
18
+
19
+ # 使った時の処理
20
+
23
- {
21
+ }
22
+
23
+        }
24
+
25
+
24
26
 
25
27
  ```