質問編集履歴
2
試したこととソースに修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -26,51 +26,45 @@
|
|
26
26
|
public static float dis;
|
27
27
|
public float EShotFlame;
|
28
28
|
private float EShotTime1;
|
29
|
-
private float EShotTIme2;
|
30
29
|
// Use this for initialization
|
31
30
|
void Start () {
|
32
31
|
Player = GameObject.FindGameObjectWithTag("Player").transform;
|
33
32
|
Muzzle1 = GameObject.Find("Muzzle1");
|
34
33
|
Muzzle2 = GameObject.Find("Muzzle2");
|
35
|
-
_HP = 2;
|
36
34
|
}
|
37
35
|
|
38
36
|
// Update is called once per frame
|
39
37
|
void Update () {
|
40
|
-
EShotTime1 += Time.deltaTime;
|
38
|
+
EShotTime1 += Time.deltaTime;//砲弾射撃レート
|
41
|
-
|
39
|
+
|
42
|
-
EnemyShot enemyshot1=Muzzle1.GetComponent<EnemyShot>();
|
40
|
+
EnemyShot enemyshot1=Muzzle1.GetComponent<EnemyShot>();//射撃メソッド取り込み
|
43
41
|
EnemyShot enemyshot2 = Muzzle2.GetComponent<EnemyShot>();
|
44
|
-
Direction=Player.transform.position-transform.position;
|
42
|
+
Direction=Player.transform.position-transform.position;//回転方向計算
|
45
43
|
var rotation=Quaternion.LookRotation(Direction);
|
46
44
|
|
47
45
|
Vector3 PlayerPos = Player.position;
|
48
46
|
dis = Vector3.Distance(PlayerPos, transform.position);
|
49
|
-
|
50
|
-
|
47
|
+
;
|
51
|
-
rotation.x = rotation.z = 0;
|
48
|
+
rotation.x = rotation.z = 0;//Y軸方向のみ回転させる
|
52
|
-
if (dis < ReactionRange)
|
49
|
+
if (dis < ReactionRange)//一定範囲内にプレイヤーが近づいたら
|
53
50
|
{
|
54
|
-
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * TurnSpeed);
|
51
|
+
transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * TurnSpeed);//砲台回転処理
|
55
|
-
if(EShotTime1>EShotFlame)
|
52
|
+
if(EShotTime1>EShotFlame)//射撃
|
56
53
|
{
|
57
54
|
enemyshot1.EShot(Muzzle1.transform);
|
55
|
+
enemyshot2.EShot( Muzzle2.transform);
|
58
56
|
EShotTime1=0;
|
59
57
|
}
|
60
|
-
|
58
|
+
|
61
|
-
{
|
62
|
-
enemyshot2.EShot( Muzzle2.transform);
|
63
|
-
EShotTIme2 = 0;
|
64
|
-
}
|
65
59
|
}
|
66
60
|
|
67
61
|
|
68
62
|
|
69
63
|
|
70
64
|
}
|
71
|
-
void Hit(Collider col)
|
65
|
+
void Hit(Collider col)//弾がヒットしたら
|
72
66
|
{
|
73
|
-
if (col.gameObject.tag == "NShell")
|
67
|
+
if (col.gameObject.tag == "NShell")//ノーマル弾
|
74
68
|
{
|
75
69
|
|
76
70
|
_HP -= 3;
|
@@ -81,7 +75,7 @@
|
|
81
75
|
Destroy(this.gameObject);
|
82
76
|
}
|
83
77
|
}
|
84
|
-
if(col.gameObject.tag=="FShell")
|
78
|
+
if(col.gameObject.tag=="FShell")//火炎弾
|
85
79
|
{
|
86
80
|
_HP -= 2;
|
87
81
|
Destroy(col.gameObject);
|
@@ -91,7 +85,7 @@
|
|
91
85
|
Destroy(this.gameObject);
|
92
86
|
}
|
93
87
|
}
|
94
|
-
if(col.gameObject.tag=="AShell")
|
88
|
+
if(col.gameObject.tag=="AShell")//水弾
|
95
89
|
{
|
96
90
|
_HP -= 5;
|
97
91
|
Destroy(col.gameObject);
|
@@ -103,11 +97,11 @@
|
|
103
97
|
}
|
104
98
|
}
|
105
99
|
}
|
106
|
-
|
107
100
|
```
|
108
101
|
|
109
102
|
###試したこと
|
110
103
|
砲弾本体に実装すべきかどうか等も検討しましたが、こちらも上手くいきませんでした。
|
104
|
+
Updateに_HPが0以下になった場合も試しましたがこれもダメでした。
|
111
105
|
|
112
106
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
113
107
|
visual studioを使用
|
1
ソースコードを当てているオブジェクトを表記
title
CHANGED
File without changes
|
body
CHANGED
@@ -110,4 +110,5 @@
|
|
110
110
|
砲弾本体に実装すべきかどうか等も検討しましたが、こちらも上手くいきませんでした。
|
111
111
|
|
112
112
|
###補足情報(言語/FW/ツール等のバージョンなど)
|
113
|
-
visual studioを使用
|
113
|
+
visual studioを使用
|
114
|
+
ソースコードはヒット目標物に当てています。
|