質問編集履歴
1
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -65,4 +65,68 @@
|
|
65
65
|
Assets/Script/Chapter10/AttackArea.cs(56,12): error CS1061: Type `UnityEngine.Component' does not contain a definition for `enabled' and no extension method `enabled' of type `UnityEngine.Component' could be found. Are you missing an assembly reference?
|
66
66
|
|
67
67
|
の二つです。
|
68
|
+
|
69
|
+
追記
|
70
|
+
---
|
71
|
+
上記のスクリプトを以下のスクリプトにしてみましたが、現状変わらず(T ^ T)
|
72
|
+
|
73
|
+
```C#
|
74
|
+
using UnityEngine;
|
75
|
+
using System.Collections;
|
76
|
+
|
77
|
+
public class AttackArea : MonoBehaviour {
|
78
|
+
CharacterStatus status;
|
79
|
+
|
68
|
-
|
80
|
+
void Start()
|
81
|
+
{
|
82
|
+
status = transform.root.GetComponent<CharacterStatus>();
|
83
|
+
}
|
84
|
+
|
85
|
+
|
86
|
+
public class AttackInfo
|
87
|
+
{
|
88
|
+
public int attackPower; // この攻撃の攻撃力.
|
89
|
+
public Transform attacker; // 攻撃者.
|
90
|
+
}
|
91
|
+
|
92
|
+
|
93
|
+
// 攻撃情報を取得する.
|
94
|
+
AttackInfo GetAttackInfo()
|
95
|
+
{
|
96
|
+
AttackInfo attackInfo = new AttackInfo();
|
97
|
+
// 攻撃力の計算.
|
98
|
+
attackInfo.attackPower = status.Power;
|
99
|
+
// 攻撃強化中
|
100
|
+
if (status.powerBoost)
|
101
|
+
attackInfo.attackPower += attackInfo.attackPower;
|
102
|
+
|
103
|
+
attackInfo.attacker = transform.root;
|
104
|
+
|
105
|
+
return attackInfo;
|
106
|
+
}
|
107
|
+
|
108
|
+
// 当たった.
|
109
|
+
void OnTriggerEnter(Collider other)
|
110
|
+
{
|
111
|
+
// 攻撃が当たった相手のDamageメッセージをおくる.
|
112
|
+
other.SendMessage("Damage",GetAttackInfo());
|
113
|
+
// 攻撃した対象を保存.
|
114
|
+
status.lastAttackTarget = other.transform.root.gameObject;
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
// 攻撃判定を有効にする.
|
119
|
+
void OnAttack()
|
120
|
+
{
|
121
|
+
GetComponent<Collider> ().enable = true;
|
122
|
+
}
|
123
|
+
|
124
|
+
|
125
|
+
// 攻撃判定を無効にする.
|
126
|
+
void OnAttackTermination()
|
127
|
+
{
|
128
|
+
GetComponent<Collider> ().enable = false;
|
129
|
+
}
|
130
|
+
}
|
131
|
+
|
132
|
+
```
|