質問編集履歴
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -132,4 +132,132 @@
|
|
132
132
|
|
133
133
|
の二つです。
|
134
134
|
|
135
|
+
|
136
|
+
|
137
|
+
追記
|
138
|
+
|
139
|
+
---
|
140
|
+
|
141
|
+
上記のスクリプトを以下のスクリプトにしてみましたが、現状変わらず(T ^ T)
|
142
|
+
|
143
|
+
|
144
|
+
|
145
|
+
```C#
|
146
|
+
|
147
|
+
using UnityEngine;
|
148
|
+
|
149
|
+
using System.Collections;
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
public class AttackArea : MonoBehaviour {
|
154
|
+
|
155
|
+
CharacterStatus status;
|
156
|
+
|
157
|
+
|
158
|
+
|
135
|
-
|
159
|
+
void Start()
|
160
|
+
|
161
|
+
{
|
162
|
+
|
163
|
+
status = transform.root.GetComponent<CharacterStatus>();
|
164
|
+
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
public class AttackInfo
|
172
|
+
|
173
|
+
{
|
174
|
+
|
175
|
+
public int attackPower; // この攻撃の攻撃力.
|
176
|
+
|
177
|
+
public Transform attacker; // 攻撃者.
|
178
|
+
|
179
|
+
}
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
// 攻撃情報を取得する.
|
186
|
+
|
187
|
+
AttackInfo GetAttackInfo()
|
188
|
+
|
189
|
+
{
|
190
|
+
|
191
|
+
AttackInfo attackInfo = new AttackInfo();
|
192
|
+
|
193
|
+
// 攻撃力の計算.
|
194
|
+
|
195
|
+
attackInfo.attackPower = status.Power;
|
196
|
+
|
197
|
+
// 攻撃強化中
|
198
|
+
|
199
|
+
if (status.powerBoost)
|
200
|
+
|
201
|
+
attackInfo.attackPower += attackInfo.attackPower;
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
attackInfo.attacker = transform.root;
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
return attackInfo;
|
210
|
+
|
211
|
+
}
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
// 当たった.
|
216
|
+
|
217
|
+
void OnTriggerEnter(Collider other)
|
218
|
+
|
219
|
+
{
|
220
|
+
|
221
|
+
// 攻撃が当たった相手のDamageメッセージをおくる.
|
222
|
+
|
223
|
+
other.SendMessage("Damage",GetAttackInfo());
|
224
|
+
|
225
|
+
// 攻撃した対象を保存.
|
226
|
+
|
227
|
+
status.lastAttackTarget = other.transform.root.gameObject;
|
228
|
+
|
229
|
+
}
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
// 攻撃判定を有効にする.
|
236
|
+
|
237
|
+
void OnAttack()
|
238
|
+
|
239
|
+
{
|
240
|
+
|
241
|
+
GetComponent<Collider> ().enable = true;
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
|
249
|
+
// 攻撃判定を無効にする.
|
250
|
+
|
251
|
+
void OnAttackTermination()
|
252
|
+
|
253
|
+
{
|
254
|
+
|
255
|
+
GetComponent<Collider> ().enable = false;
|
256
|
+
|
257
|
+
}
|
258
|
+
|
259
|
+
}
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
```
|