質問編集履歴
5
誤字
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
```c#
|
20
20
|
|
21
|
-
|
21
|
+
using System.Collections;
|
22
22
|
|
23
23
|
using System.Collections.Generic;
|
24
24
|
|
4
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -16,9 +16,9 @@
|
|
16
16
|
|
17
17
|
|
18
18
|
|
19
|
-
|
19
|
+
```c#
|
20
20
|
|
21
|
-
using System.Collections;
|
21
|
+
コードusing System.Collections;
|
22
22
|
|
23
23
|
using System.Collections.Generic;
|
24
24
|
|
@@ -117,3 +117,5 @@
|
|
117
117
|
}
|
118
118
|
|
119
119
|
}
|
120
|
+
|
121
|
+
```
|
3
ソースコードわすれてた
test
CHANGED
File without changes
|
test
CHANGED
@@ -13,3 +13,107 @@
|
|
13
13
|
<コンソール>
|
14
14
|
|
15
15
|
Assets\Player.cs(9,12): error CS0246: The type or namespace name 'GroundCheck' could not be found (are you missing a using directive or an assembly reference?)
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
<ソースコード>
|
20
|
+
|
21
|
+
using System.Collections;
|
22
|
+
|
23
|
+
using System.Collections.Generic;
|
24
|
+
|
25
|
+
using UnityEngine;
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
public class Player : MonoBehaviour
|
30
|
+
|
31
|
+
{
|
32
|
+
|
33
|
+
//インスペクターで設定する
|
34
|
+
|
35
|
+
public float speed;
|
36
|
+
|
37
|
+
public GroundCheck ground; //new
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
//プライベート変数
|
42
|
+
|
43
|
+
private Animator anim = null;
|
44
|
+
|
45
|
+
private Rigidbody2D rb = null;
|
46
|
+
|
47
|
+
private bool isGround = false; //new
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
void Start()
|
52
|
+
|
53
|
+
{
|
54
|
+
|
55
|
+
//コンポーネントのインスタンスを捕まえる
|
56
|
+
|
57
|
+
anim = GetComponent<Animator>();
|
58
|
+
|
59
|
+
rb = GetComponent<Rigidbody2D>();
|
60
|
+
|
61
|
+
}
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
void Update()
|
66
|
+
|
67
|
+
{
|
68
|
+
|
69
|
+
//接地判定を得る
|
70
|
+
|
71
|
+
isGround = ground.IsGround(); //new
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
//キー入力されたら行動する
|
76
|
+
|
77
|
+
float horizontalKey = Input.GetAxis("Horizontal");
|
78
|
+
|
79
|
+
float xSpeed = 0.0f;
|
80
|
+
|
81
|
+
if (horizontalKey > 0)
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
transform.localScale = new Vector3(1, 1, 1);
|
86
|
+
|
87
|
+
anim.SetBool("run", true);
|
88
|
+
|
89
|
+
xSpeed = speed;
|
90
|
+
|
91
|
+
}
|
92
|
+
|
93
|
+
else if (horizontalKey < 0)
|
94
|
+
|
95
|
+
{
|
96
|
+
|
97
|
+
transform.localScale = new Vector3(-1, 1, 1);
|
98
|
+
|
99
|
+
anim.SetBool("run", true);
|
100
|
+
|
101
|
+
xSpeed = -speed;
|
102
|
+
|
103
|
+
}
|
104
|
+
|
105
|
+
else
|
106
|
+
|
107
|
+
{
|
108
|
+
|
109
|
+
anim.SetBool("run", false);
|
110
|
+
|
111
|
+
xSpeed = 0.0f;
|
112
|
+
|
113
|
+
}
|
114
|
+
|
115
|
+
rb.velocity = new Vector2(xSpeed, rb.velocity.y);
|
116
|
+
|
117
|
+
}
|
118
|
+
|
119
|
+
}
|
2
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -2,7 +2,9 @@
|
|
2
2
|
|
3
3
|
目次<PlayerでGroundCheckを読みこもう>ができません
|
4
4
|
|
5
|
+
publicな変数がインスペクターに表示されないせいでGroundCheckをその変数に入れることができません
|
5
6
|
|
7
|
+
誰か解決案をくれるとありがたいです。
|
6
8
|
|
7
9
|
|
8
10
|
|
1
書式の改善
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
-
https://dkrevel.com/makegame-beginner/make-2d-action-ground/このサイトの
|
1
|
+
https://dkrevel.com/makegame-beginner/make-2d-action-ground/このサイトの
|
2
2
|
|
3
|
+
目次<PlayerでGroundCheckを読みこもう>ができません
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
エラーはここです
|
10
|
+
|
3
|
-
|
11
|
+
<コンソール>
|
12
|
+
|
13
|
+
Assets\Player.cs(9,12): error CS0246: The type or namespace name 'GroundCheck' could not be found (are you missing a using directive or an assembly reference?)
|