.
This commit is contained in:
parent
efdeae9c58
commit
4e0c7121c0
@ -10,16 +10,43 @@ public class MonsterController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
public State monsterState;
|
public State monsterState;
|
||||||
|
public float attackDist = 2.0f;
|
||||||
|
public float traceDist = 10.0f;
|
||||||
|
|
||||||
|
public bool isDie = false;
|
||||||
|
|
||||||
|
public Transform playerTr, monsterTr;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
|
playerTr = GameObject.Find("Player").GetComponent<Transform>();
|
||||||
|
monsterTr = transform;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update is called once per frame
|
IEnumerator CheckMonsterState()
|
||||||
void Update()
|
|
||||||
{
|
{
|
||||||
|
while (!isDie)
|
||||||
|
{
|
||||||
|
// 거리 계산
|
||||||
|
float distance = Vector3.Distance(playerTr.position, monsterTr.position);
|
||||||
|
|
||||||
|
if (distance <= attackDist)
|
||||||
|
{
|
||||||
|
monsterState = State.ATTACK;
|
||||||
}
|
}
|
||||||
|
else if (distance <= traceDist)
|
||||||
|
{
|
||||||
|
monsterState = State.TRACE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
monsterState = State.IDLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield return new WaitForSeconds(0.3f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user