Page 424 - MDP2022-3
P. 424

void  Update()
                     {
                             if  (stun  ==  false)
                             {
                                     freezevelocity();
                                     navAgent.SetDestination(target.position);
                             }


                     }





                     private  void  OnTriggerEnter(Collider  other)
                     {


                             if  (other.tag  ==  "Player"  &&  isCanKill)
                             {
                                     isKilling  =  true;
                                     isCanKill  =  false;
                                     audiosourece.clip  =  catch_audio;
                                     audiosourece.Play();
                                     StartCoroutine(killPlayer());
                                     animator.SetBool("isWalk",  false);
                                     navAgent.isStopped  =  true;
                             }
                     }






                     IEnumerator  killPlayer()
                     {
                             mainCamera.SetActive(false);
                             subCamera.SetActive(true);  //subCamera사용


                             //subCamera를  지속적으로  몬스터의  앞으로  이동시킴,  몬스터가  플레이어를  무는듯한  효과


                             for  (int  i  =  0;  i  <  150;  i++)
                             {
                                     subCamera.transform.position  =  playerKillPos.position  +  new  Vector3(0f,  0f,  0f);
                                     subCamera.transform.eulerAngles  =  new  Vector3(0,  playerKillPos.eulerAngles.y,  0);
                                     yield  return  null;
                             }
                             GameOverCanvas.instance.die();
                             Destroy(gameObject);
                     }
   419   420   421   422   423   424   425   426   427   428   429