質問編集履歴
4
バレットコントローラー追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
このコードの何処を変更すれば良いか分かりませんでした。教えて頂けたら幸いです。
|
7
7
|
|
8
8
|
### 該当のソースコード
|
9
|
+
|
9
|
-
```C#
|
10
|
+
```C#
|
10
11
|
using UnityEngine;
|
11
12
|
using System.Collections;
|
12
13
|
|
@@ -27,10 +28,24 @@
|
|
27
28
|
}
|
28
29
|
}
|
29
30
|
```
|
31
|
+
```C#
|
32
|
+
using UnityEngine;
|
33
|
+
using System.Collections;
|
30
34
|
|
35
|
+
public class BulletController : MonoBehaviour
|
36
|
+
{
|
37
|
+
void Update()
|
38
|
+
{
|
39
|
+
transform.Translate(0, 0.2f, 0);
|
31
40
|
|
41
|
+
if (transform.position.y > 5)
|
42
|
+
{
|
43
|
+
Destroy(gameObject);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
}
|
47
|
+
```
|
32
48
|
|
33
49
|
|
34
|
-
|
35
50
|
### 補足情報(FW/ツールのバージョンなど)
|
36
51
|
Unity
|
3
ソースコード変更
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
Unity2D 玉
|
1
|
+
Unity2D 玉発射の方向変更
|
body
CHANGED
File without changes
|
2
ソースコード修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,7 +26,6 @@
|
|
26
26
|
}
|
27
27
|
}
|
28
28
|
}
|
29
|
-
}
|
30
29
|
```
|
31
30
|
|
32
31
|
|
1
ソースコード修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -6,23 +6,32 @@
|
|
6
6
|
このコードの何処を変更すれば良いか分かりませんでした。教えて頂けたら幸いです。
|
7
7
|
|
8
8
|
### 該当のソースコード
|
9
|
+
```C#
|
10
|
+
using UnityEngine;
|
9
|
-
|
11
|
+
using System.Collections;
|
10
|
-
{
|
11
|
-
Instantiate(bulletPrefab, transform.position, Quaternion.identity);
|
12
|
-
}
|
13
|
-
}
|
14
12
|
|
13
|
+
public class RocketController : MonoBehaviour {
|
14
|
+
|
15
|
+
public GameObject bulletPrefab;
|
16
|
+
|
17
|
+
void Update () {
|
18
|
+
if (Input.GetKey (KeyCode.LeftArrow)) {
|
19
|
+
transform.Translate (-0.1f, 0, 0);
|
20
|
+
}
|
21
|
+
if (Input.GetKey (KeyCode.RightArrow)) {
|
22
|
+
transform.Translate ( 0.1f, 0, 0);
|
23
|
+
}
|
24
|
+
if (Input.GetKeyDown (KeyCode.Space)) {
|
25
|
+
Instantiate (bulletPrefab, transform.position, Quaternion.identity);
|
26
|
+
}
|
27
|
+
}
|
15
28
|
}
|
16
|
-
|
17
|
-
```ここに言語名を入力
|
18
|
-
|
29
|
+
}
|
19
30
|
```
|
20
31
|
|
21
|
-
### 試したこと
|
22
32
|
|
23
|
-
色々試しましたが、分かりませんでした。
|
24
33
|
|
25
34
|
|
35
|
+
|
26
36
|
### 補足情報(FW/ツールのバージョンなど)
|
27
|
-
|
28
|
-
|
37
|
+
Unity
|