Page 414 - MDP2022-3
P. 414
private void Awake()
{
target = playerTransform;
animator = GetComponent<Animator>();
audioSourece = GetComponent<AudioSource>();
navAgent = GetComponent<NavMeshAgent>();
rigid = GetComponent<Rigidbody>();
navstop(); // 시작할때 플레이어 추적을 멈춤
timer = 0f;
waitingTime = 3;
animator.SetBool("IsStun", false);
}
private bool eatFinish = false;
public IEnumerator Eat(Transform target)
{
transform.Translate(new Vector3(0f, -2f, 0f));
navstop();
while (!eatFinish)
{
target.position = foodTransform.position;
yield return null;
}
//yield return new WaitForSeconds(2f);
}
public void EatFinish()
{
eatFinish = true;
audioSourece.Stop();
Destroy(food);
isCanUseEat = true;
isCanFindFood = true;
can_stun = true;
brain_count += 1;
navgo();
if (brain_count == 3)
{
animator.SetBool("brain",true);
animator.SetBool("CatchKey", false);
can_stun = false;
navstop();
}
target = playerTransform;
}