質問編集履歴
4
無関係のコードを削除しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,109 +1,13 @@
|
|
1
|
-
### 前提・実現したいこと
|
2
1
|
### 発生している問題・エラーメッセージ
|
3
|
-
|
4
|
-

|
5
|
-
|
2
|
+
弾を二重に作って、発射させていますが、
|
6
3
|
移動先で作り始めると、移動前で作っていた弾の生成が途中で中断されてしまいます。
|
7
4
|
そして、移動先で、前回の続きから作り始めてしまいます。
|
8
5
|
|
9
6
|
最初の位置で弾が最後まで生成され終わり、その最中であっても、移動先で弾の生成を初めて終わらせたいです。
|
10
7
|
### 該当のソースコード
|
11
|
-
|
12
8
|
```C#
|
13
|
-
//移動座標
|
14
|
-
public Vector3 aP1;
|
15
|
-
public Vector3 aP2;
|
16
|
-
public Vector3 aP3;
|
17
|
-
public Vector3 aP4;
|
18
|
-
public Vector3 aP5;
|
19
|
-
public Vector3 aP6;
|
20
|
-
|
21
|
-
//待機時間
|
22
|
-
public float startWait;
|
23
|
-
|
24
|
-
private IEnumerator m_Coroutine;
|
25
|
-
|
26
|
-
//生成するPrefab
|
27
|
-
public GameObject prefab;
|
28
|
-
//生成数
|
29
|
-
public int count;
|
30
|
-
//中心点のオブジェクト
|
31
|
-
public GameObject center;
|
32
|
-
//距離1
|
33
|
-
public float distance;
|
34
|
-
//距離2
|
35
|
-
public float distance2;
|
36
|
-
//中心点の方向に向けるか
|
37
|
-
public bool isLookAtCenter = true;
|
38
|
-
|
39
|
-
IEnumerator Start()
|
40
|
-
{
|
41
|
-
yield return new WaitForSeconds(startWait);
|
42
|
-
|
43
|
-
AttackSequence(1);
|
44
|
-
yield return new WaitForSeconds(2f);
|
45
|
-
|
46
|
-
AttackSequence(2);
|
47
|
-
yield return new WaitForSeconds(2f);
|
48
|
-
|
49
|
-
AttackSequence(3);
|
50
|
-
yield return new WaitForSeconds(2f);
|
51
|
-
|
52
|
-
AttackSequence(4);
|
53
|
-
yield return new WaitForSeconds(2f);
|
54
|
-
|
55
|
-
AttackSequence(5);
|
56
|
-
yield return new WaitForSeconds(2f);
|
57
|
-
|
58
|
-
AttackSequence(6);
|
59
|
-
yield break;
|
60
|
-
}
|
61
|
-
|
62
|
-
public Sequence AttackSequence(int num)
|
63
|
-
{
|
64
|
-
Sequence seq = DOTween.Sequence();
|
65
|
-
barrage_1 = this.gameObject.GetComponent<barrage_1>();
|
66
|
-
|
67
|
-
Vector3 aP = new Vector3(0,0,0);
|
68
|
-
|
69
|
-
if (num == 1)
|
70
|
-
{
|
71
|
-
aP = aP1;
|
72
|
-
}
|
73
|
-
else if(num == 2)
|
74
|
-
{
|
75
|
-
aP = aP2;
|
76
|
-
}
|
77
|
-
else if (num == 3)
|
78
|
-
{
|
79
|
-
aP = aP3;
|
80
|
-
}
|
81
|
-
else if (num == 4)
|
82
|
-
{
|
83
|
-
aP = aP4;
|
84
|
-
}
|
85
|
-
else if (num == 5)
|
86
|
-
{
|
87
|
-
aP = aP5;
|
88
|
-
}
|
89
|
-
else if (num == 6)
|
90
|
-
{
|
91
|
-
aP = aP6;
|
92
|
-
}
|
93
|
-
//移動
|
94
|
-
seq.Append(transform.DOMove(aP, 2f).SetEase(Ease.OutCubic).OnComplete(() =>
|
95
|
-
{
|
96
|
-
// コルーチン開始
|
97
|
-
m_Coroutine = barrage_1.Generate(prefab, count, center, distance, distance2, isLookAtCenter);
|
98
|
-
barrage_1.StartCoroutine(m_Coroutine);
|
99
|
-
}));
|
100
|
-
|
101
|
-
return seq;
|
102
|
-
}
|
103
|
-
```
|
104
|
-
```C#
|
105
9
|
//↓これのせい
|
106
|
-
public IEnumerator Generate(GameObject prefab, int count, GameObject center, float distance,
|
10
|
+
public IEnumerator Generate(GameObject prefab, int count, GameObject center, float distance, bool isLookAtCenter = true)
|
107
11
|
{
|
108
12
|
Vector3 uP = new Vector3(0, 1, 0);
|
109
13
|
//中心のオブジェクトの位置を取得
|
3
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -90,7 +90,7 @@
|
|
90
90
|
{
|
91
91
|
aP = aP6;
|
92
92
|
}
|
93
|
-
//
|
93
|
+
//移動
|
94
94
|
seq.Append(transform.DOMove(aP, 2f).SetEase(Ease.OutCubic).OnComplete(() =>
|
95
95
|
{
|
96
96
|
// コルーチン開始
|
2
誤字
title
CHANGED
File without changes
|
body
CHANGED
@@ -93,8 +93,7 @@
|
|
93
93
|
//下に移動
|
94
94
|
seq.Append(transform.DOMove(aP, 2f).SetEase(Ease.OutCubic).OnComplete(() =>
|
95
95
|
{
|
96
|
-
// コルーチン開始
|
96
|
+
// コルーチン開始
|
97
|
-
//シーケンス後に呼び出しにしないと、AttackSequence();が実行された後すぐに実行されてしまい、到着前に発動してしまう
|
98
97
|
m_Coroutine = barrage_1.Generate(prefab, count, center, distance, distance2, isLookAtCenter);
|
99
98
|
barrage_1.StartCoroutine(m_Coroutine);
|
100
99
|
}));
|
1
追記しました
title
CHANGED
File without changes
|
body
CHANGED
@@ -10,6 +10,19 @@
|
|
10
10
|
### 該当のソースコード
|
11
11
|
|
12
12
|
```C#
|
13
|
+
//移動座標
|
14
|
+
public Vector3 aP1;
|
15
|
+
public Vector3 aP2;
|
16
|
+
public Vector3 aP3;
|
17
|
+
public Vector3 aP4;
|
18
|
+
public Vector3 aP5;
|
19
|
+
public Vector3 aP6;
|
20
|
+
|
21
|
+
//待機時間
|
22
|
+
public float startWait;
|
23
|
+
|
24
|
+
private IEnumerator m_Coroutine;
|
25
|
+
|
13
26
|
//生成するPrefab
|
14
27
|
public GameObject prefab;
|
15
28
|
//生成数
|
@@ -25,26 +38,65 @@
|
|
25
38
|
|
26
39
|
IEnumerator Start()
|
27
40
|
{
|
28
|
-
|
41
|
+
yield return new WaitForSeconds(startWait);
|
42
|
+
|
29
43
|
AttackSequence(1);
|
30
|
-
//2秒待つ
|
31
44
|
yield return new WaitForSeconds(2f);
|
32
45
|
|
33
46
|
AttackSequence(2);
|
34
47
|
yield return new WaitForSeconds(2f);
|
48
|
+
|
49
|
+
AttackSequence(3);
|
50
|
+
yield return new WaitForSeconds(2f);
|
51
|
+
|
52
|
+
AttackSequence(4);
|
53
|
+
yield return new WaitForSeconds(2f);
|
54
|
+
|
55
|
+
AttackSequence(5);
|
56
|
+
yield return new WaitForSeconds(2f);
|
57
|
+
|
58
|
+
AttackSequence(6);
|
59
|
+
yield break;
|
35
60
|
}
|
36
61
|
|
37
|
-
public Sequence AttackSequence()
|
62
|
+
public Sequence AttackSequence(int num)
|
38
|
-
{
|
63
|
+
{
|
39
64
|
Sequence seq = DOTween.Sequence();
|
40
65
|
barrage_1 = this.gameObject.GetComponent<barrage_1>();
|
66
|
+
|
41
|
-
|
67
|
+
Vector3 aP = new Vector3(0,0,0);
|
68
|
+
|
69
|
+
if (num == 1)
|
70
|
+
{
|
71
|
+
aP = aP1;
|
72
|
+
}
|
73
|
+
else if(num == 2)
|
74
|
+
{
|
75
|
+
aP = aP2;
|
76
|
+
}
|
77
|
+
else if (num == 3)
|
78
|
+
{
|
79
|
+
aP = aP3;
|
80
|
+
}
|
81
|
+
else if (num == 4)
|
82
|
+
{
|
83
|
+
aP = aP4;
|
84
|
+
}
|
85
|
+
else if (num == 5)
|
86
|
+
{
|
87
|
+
aP = aP5;
|
88
|
+
}
|
89
|
+
else if (num == 6)
|
90
|
+
{
|
91
|
+
aP = aP6;
|
92
|
+
}
|
93
|
+
//下に移動
|
42
94
|
seq.Append(transform.DOMove(aP, 2f).SetEase(Ease.OutCubic).OnComplete(() =>
|
43
95
|
{
|
44
|
-
// コルーチン開始
|
96
|
+
// コルーチン開始
|
97
|
+
//シーケンス後に呼び出しにしないと、AttackSequence();が実行された後すぐに実行されてしまい、到着前に発動してしまう
|
45
98
|
m_Coroutine = barrage_1.Generate(prefab, count, center, distance, distance2, isLookAtCenter);
|
46
99
|
barrage_1.StartCoroutine(m_Coroutine);
|
47
|
-
|
48
100
|
}));
|
49
101
|
|
50
102
|
return seq;
|