Unity¤Ë´ØÏ¢¤¹¤ëµ­»ö¤Ç¤¹

¡¡°Ê²¼¤ÎÆâÍƤǽçÈ֤˼ÂÁõ¤ò¿Ê¤á¤Æ¤¤¤­¤Þ¤¹¡£

¼ê½ç£±£°¡¡¡Ý¥³¥é¥¤¥À¡¼Æ±»Î¤Î¿¯ÆþȽÄê¤Î¼ÂÁõ¡Ý
£²£°¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¨¥Í¥ß¡¼¤Î¥³¥é¥¤¥À¡¼¤ËÂФ·¤Æ¤Î¿¯ÆþȽÄê½èÍý¤òÄɲ乤ë
£²£±¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¿¯ÆþȽÄê¤ÎºÝ¤Ë¥¨¥Í¥ß¡¼¤È¥Ð¥ì¥Ã¥ÈξÊý¤òÇ˲õ¤¹¤ë½èÍý¤òÄɲ乤ë



¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

¡¡¡¦OnTriggerEnter2D ¥á¥½¥Ã¥É
¡¡¡¦Tag ¤ÎÀßÄê
¡¡¡¦½èÍý¤Î¥á¥½¥Ã¥É²½



£²£°¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¨¥Í¥ß¡¼¤Î¥³¥é¥¤¥À¡¼¤ËÂФ·¤Æ¤Î¿¯ÆþȽÄê½èÍý¤òÄɲ乤ë

£±¡¥Àß·×


¡¡¥¨¥Í¥ß¡¼¤òºîÀ®¤·¤Þ¤·¤¿¤Î¤Ç¡¢¼¡¤Ï¡¢¥¨¥Í¥ß¡¼¤È¥Ð¥ì¥Ã¥È¤È¤¬ÀÜ¿¨¤¹¤ë¤¿¤á¤Î½èÍý¤ò¹Í¤¨¤Æ¡¢¼ÂÁõ¤ò¹Ô¤Ã¤Æ¤¤¤­¤Þ¤¹¡£

¡¡¤¤¤ï¤æ¤ë¡ÖÅö¤¿¤êȽÄê¡×¤È¸Æ¤Ð¤ì¤ë¤â¤Î¤Ç¤¹¡£
Unity ¤Ë¤Ï¼ç¤Ë¡¢¥³¥é¥¤¥À¡¼Æ±»Î¤¬ÀÜ¿¨¤·¤¿ºÝ¤È¡¢¥³¥é¥¤¥À¡¼¤¬¤â¤¦ÊÒÊý¤Î¥³¥é¥¤¥À¡¼¤Ë¿¯Æþ¤·¤¿ºÝ¤Î£²¤Ä¤ÎÊýË¡¤ÇÅö¤¿¤êȽÄê¤òÍÑ°Õ¤·¡¢³Îǧ¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

¡¡º£²ó¤Ï£²¤ÄÌܤΡ¢¥³¥é¥¤¥À¡¼¤¬¤â¤¦ÊÒÊý¤Î¥³¥é¥¤¥À¡¼¤Ë¿¯Æþ¤·¤¿ºÝ¤ÎȽÄê¤ÎÊý¸þ¤Ç¼ÂÁõ¤ò¹Ô¤Ã¤Æ¤¤¤­¤Þ¤¹¡£
¤³¤Î½èÍý¤Ï¡¢Unity ¤¬ÍÑ°Õ¤·¤Æ¤¤¤ë OnTriggerEnter2D ¥á¥½¥Ã¥É¤òÍøÍѤ¹¤ë¤³¤È¤Ç¼ÂÁõ¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

¡¡¤³¤Î OnTriggerEnter2D ¥á¥½¥Ã¥É¤òÍøÍѤ·¤¿È½Äê¤ò¹Ô¤¦¤¿¤á¤Ë¤Ï¡¢¥Ð¥ì¥Ã¥È¤«¥¨¥Í¥ß¡¼¤Î¤¤¤º¤ì¤«¤Î¥³¥é¥¤¥À¡¼¡¢¤¢¤ë¤¤¤ÏξÊý¤Î¥³¥é¥¤¥À¡¼¤Î IsTrigger ¤Î¥Á¥§¥Ã¥¯¤¬¥ª¥ó¤Ë¤Ê¤Ã¤Æ¤¤¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤½¤Î¤¿¤á¤Ë¡¢»öÁ°¤Ë¡¢¥Ð¥ì¥Ã¥È¤Î¥×¥ì¥Õ¥¡¥Ö¡¦¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤È¡¢¥¨¥Í¥ß¡¼¤Î¥³¥é¥¤¥À¡¼¤Ï¡¢¤É¤Á¤é¤â IsTrigger ¤Î¥Á¥§¥Ã¥¯¤òÆþ¤ì¤Æ¥ª¥ó¤Î¾õÂ֤ˤ·¤Æ¤¢¤ê¤Þ¤¹¡£
Ç°¤Î¤¿¤á¡¢³Îǧ¤·¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡£


Bullet ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È



EnemySet ¥²¡¼¥ª¥Ö¥¸¥§¥¯¥È



¡¡¤â¤·¤â IsTrigger ¤Ë¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤Ê¤±¤ì¤Ð¡¢¤³¤³¤ÇÆþ¤ì¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£


£²¡¥¡ãOnTriggerEnter2D ¥á¥½¥Ã¥É¡ä


¡¡Unity¤ÎÍÑ°Õ¤·¤Æ¤¤¤ë Collider ¥¯¥é¥¹¤Î»ý¤Ä¥á¥½¥Ã¥É¤Î£±¤Ä¤Ç¤¹¡£
¤³¤Î¥á¥½¥Ã¥É¤¬µ­½Ò¤µ¤ì¤¿¥¹¥¯¥ê¥×¥È¤Î¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤ë¥³¥é¥¤¥À¡¼¤ò»ý¤Ä¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¡Ê¥­¥ã¥é¡Ë¤¬¡¢Â¾¤Î¥³¥é¥¤¥À¡¼¤ò»ý¤Ä¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÄ̲ᤷ¤¿ºÝ¤ËÀÜ¿¨(¿¯Æþ)ȽÄê¤ò¹Ô¤¦¥á¥½¥Ã¥É¤Ç¤¹¡£

¡¡¤³¤Î¥¹¥¯¥ê¥×¥È¤¬¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤ÎÃæ¤Ë¡¢¿¯Æþ¤·¤¿¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤¬¤¢¤ë¾ì¹ç¡¢
¤½¤Î¾ðÊó¤ò Collider ·¿¤Ç¼èÆÀ¤·¡¢¥á¥½¥Ã¥ÉÆâ¤ÇÍøÍѤǤ­¤ë¾õÂ֤ˤ·¤Æ¤¯¤ì¤Þ¤¹¡£

¡¡Ä̾拾¥é¥¤¥À¡¼¤ò»ý¤Ä¥ª¥Ö¥¸¥§¥¯¥ÈƱ»Î¤ÏÀÜ¿¨¤·Ää»ß¤·¤Þ¤¹¤¬¡¢¤¤¤º¤ì¤«ÊÒÊý¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤Î IsTrigger ¤Î¥¹¥¤¥Ã¥Á¤¬¥ª¥ó¤Ë¤Ê¤Ã¤Æ¤¤¤ë¾ì¹ç¡¢
¥³¥é¥¤¥À¡¼¤ò»ý¤Ä¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÄ̲á(¿¯Æþ)¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤½¤ÎºÝ¤Ë¡¢¤³¤Î¥á¥½¥Ã¥É¤¬¿¯ÆþȽÄê¤ò¹Ô¤¤¤Þ¤¹¡£

    // IsTrigger¤¬¥ª¥ó¤Î¥³¥é¥¤¥À¡¼¤ò»ý¤Ä¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÄ̲ᤷ¤¿¾ì¹ç¤Ë¸Æ¤Ó½Ð¤µ¤ì¤ë¡¢¥³¡¼¥ë¥Ð¥Ã¥¯¡¦¥á¥½¥Ã¥É
    private void OnTriggerEnter2D(Collider2D other) {¡¡¡¡//¡¡<=¡¡other ¤ÏÊÑ¿ô̾¤Ê¤Î¤Ç¡¢¼«Í³¤Ë̾Á°¤òÉÕ¤±¤é¤ì¤ë

        // ½èÍý¤ò½ñ¤¯

¡¡¡¡¡¡¡¡// other ÊÑ¿ô¤Ë¤Ï¿¯Æþ¤·¤Æ¤­¤¿¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤Î¾ðÊó¤¬Æþ¤Ã¤Æ¤¤¤ë¤Î¤Ç¡¢ÍøÍѤǤ­¤ë

    }

¡¡¿¯ÆþȽÄê¤Ï¥³¥é¥¤¥À¡¼¤Ç¤¢¤ì¤ÐÈ¿±þ¤·¤Æ¤·¤Þ¤¦¤¿¤á¡¢²¿¤âÀ©¸Â¤ò¤«¤±¤Ê¤¤¤È¥Ð¥ì¥Ã¥È°Ê³°¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤Ë¤âÈ¿±þ¤·¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢Î㤨¤Ð¡¢¥¨¥Í¥ß¡¼¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤¬¿¯Æþ¤·¤¿¾ì¹ç¤Ç¤¢¤Ã¤Æ¤â¿¯ÆþȽÄ꤬ȯÀ¸¤·¤Æ¤·¤Þ¤¤¤Þ¤¹¡£

¡¡¤½¤Î¤¿¤á¿¤¯¤Î¾ì¹ç¤Ï¡¢Tag ¤Ê¤É¤Î¾ðÊó¤òÍøÍѤ·¤Æ¡¢¿¯ÆþȽÄê¤ò¹Ô¤¦ÂоݤȤʤ륲¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÀ©¸æ¤·¤ÆÍøÍѤò¤·¤Þ¤¹¡£


»²¹Í¥µ¥¤¥È
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
OnTriggerEnter
https://docs.unity3d.com/ja/current/ScriptReferenc...


£³¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¨¥Í¥ß¡¼¤Î¥³¥é¥¤¥À¡¼¤Ë¥Ð¥ì¥Ã¥È¤Î¥³¥é¥¤¥À¡¼¤¬¿¯Æþ¤·¤¿ºÝ¤ÎȽÄê½èÍý¤òÄɲ乤ë


¡¡À߷פò»²¹Í¤Ë¤·¤Ê¤¬¤é¡¢ OnTriggerEnter2D ¥á¥½¥Ã¥É¤òÍøÍѤ·¤Æ¿¯ÆþȽÄê¤Î½èÍý¤òµ­½Ò¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¤Þ¤¿²èÌ̾å¤Ç¤Ï¿¯ÆþȽÄê¤Î³Îǧ¤¬½ÐÍè¤Þ¤»¤ó¤Î¤Ç¡¢OnTriggerEnter2D ¥á¥½¥Ã¥ÉÆâ¤Ë Debug.Log ¥á¥½¥Ã¥É¤òÍÑ°Õ¤·¤Æ¡¢Console ¥Ó¥å¡¼¤ÇµóÆ°¤Î³Îǧ¤ò¹Ô¤¤¤Þ¤·¤ç¤¦¡£


EnemyController.cs


¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤ò¹Ô¤¤¤Þ¤¹¡£


£´¡¥¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¥¹¥¯¥ê¥×¥È¤Î½¤Àµ¤¬´°À®¤·¤¿¤é¡¢¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¿¯ÆþȽÄê¤Î³Îǧ¤ò¹Ô¤¤¤Þ¤¹¡£
¥¨¥Í¥ß¡¼¤ËÂФ·¤Æ¥Ð¥ì¥Ã¥È¤òȯ¼Í¤·¤Æ¥³¥é¥¤¥À¡¼Æ±»Î¤òÀÜ¿¨¤µ¤»¤Æ¤¯¤À¤µ¤¤¡£
Console ¥Ó¥å¡¼¤Ë¡¢Debug.Log ¥á¥½¥Ã¥É¤Ç»ØÄꤷ¤¿ "¿¯Æþ¤·¤¿¥ª¥Ö¥¸¥§¥¯¥È̾ : Bullet(Clone)" ¤È¡¢
¥×¥ì¥Õ¥¡¥Ö¤«¤éÀ¸À®¤µ¤ì¤¿¥Ð¥ì¥Ã¥È¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î̾Á°¤¬É½¼¨¤µ¤ì¤ì¤Ð¿¯ÆþȽÄê¤ÎÀ©¸æ¤ÏÀ®¸ù¤Ç¤¹¡£

¡¡¤Þ¤¿¿¯ÆþȽÄê¤Î̾Á°¤Î¤È¤ª¤ê¡¢¥Ð¥ì¥Ã¥È¤Î¥³¥é¥¤¥À¡¼¤Ï¡¢¥¨¥Í¥ß¡¼¤Î¥³¥é¥¤¥À¡¼¤òÄ̲ᤷ¤ÆÆͤ­È´¤±¤Æ¤¤¤¯¤³¤È¤¬Ê¬¤«¤ê¤Þ¤¹¡£


¡ã¼Â¹ÔÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯


¡¡¤â¤·¤â¥¨¥Í¥ß¡¼¤¬°ÜÆ°¤·¤Æ¤¤¤Æ¡¢¥Ð¥ì¥Ã¥È¤òÅö¤Æ¤Ë¤¯¤¤¾ì¹ç¤Ë¤Ï¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤Ë¤¢¤ë¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°¤Î½èÍý¤ò°ì»þ¥³¥á¥ó¥È¥¢¥¦¥È¤·¤Æ¤¯¤À¤µ¤¤¡£
½èÍý¤ÎÀèƬ¤ËȾ³Ñ¥¹¥é¥Ã¥·¥å£²¤Ä¤òµ­½Ò¤¹¤ì¤Ð¤½¤Î¹Ô¤Ï¥³¥á¥ó¥È¥¢¥¦¥È¤µ¤ì¤Æ¡¢½èÍý¤Ï¼Â¹Ô¤µ¤ì¤Ê¤¯¤Ê¤ê¤Þ¤¹¡£

¡¡¥Ç¥Ð¥Ã¥°¤ò¹Ô¤¦ºÝ¤Ë¤Ï¡¢Æä˵­½Ò¤¬¤Ê¤¯¤Æ¤â¡¢¼«Ê¬¤Ç¤ä¤ê¤ä¤¹¤¤ÊýË¡¤ò¸«¤Ä¤±¤Æ¤½¤ì¤ò¼ÂÁ©¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¤Ê¤ª¥³¥á¥ó¥È¥¢¥¦¥È¤·¤¿¾ì¹ç¤Ë¤Ï¡¢¥Ç¥Ð¥Ã¥°¤¬½ªÎ»¤·¤¿¤é¥³¥á¥ó¥È¥¢¥¦¥È¤Î²ò½ü¤ò˺¤ì¤Ê¤¤¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£



¡¡Ìµ»ö¤ËȽÄ꤬¼è¤ì¤Þ¤·¤¿¡£¤Ç¤¹¤¬¤³¤Î¤Þ¤Þ¤Ç¤¹¤È¡¢¥Ð¥ì¥Ã¥È°Ê³°¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ·¤Æ¤â¿¯ÆþȽÄê¤ò¹Ô¤Ã¤Æ¤·¤Þ¤¤¤Þ¤¹¡£
»î¤·¤Ë¡¢Enemy ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÊ£À½¤·¤Æ¡¢Æ±¤¸°ÌÃÖ¤ËÇÛÃÖ¤·¤Æ¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
Console ¥Ó¥å¡¼¤Ë¿¯ÆþȽÄ꤬ɽ¼¨¤µ¤ì¤Þ¤¹¡£
¡¡
¡¡¤³¤ì¤Ï Tag ¤òÍøÍѤ¹¤ë¤³¤È¤Ç¡¢ÆÃÄê¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤È¤Î¤ß¿¯ÆþȽÄê¤ò¹Ô¤¦¤è¤¦¤Ë¤¹¤ëÀ©¸æ¤¬²Äǽ¤Ç¤¹¡£
¼¡¤Î¼ê½ç¤Ç¤Ï¡¢Tag ¤ÎÅÐÏ¿¤ÈÀßÄê¤ò¹Ô¤¤¡¢¤½¤Î¾å¤Ç¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤Æ¤¤¤­¤Þ¤¹¡£


£µ¡¥¥Ð¥ì¥Ã¥È¤Î¥×¥ì¥Õ¥¡¥Ö¡¦¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë Tag ¤ÎÀßÄê¤ò¹Ô¤¦


¡¡Prefabs ¥Õ¥©¥ë¥À¤Ë¤¢¤ë Bullet ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÁªÂò¤·¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Î°ìÈÖ¾å¤Ë¤¢¤ë Open Prefab ¥Ü¥¿¥ó¤ò²¡¤·¤ÆÊÔ½¸¥â¡¼¥É¤Ë¤·¤Þ¤¹¡£

¡¡¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Î°ìÈÖ¾å¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î̾Á°¤Îº¸²¼¤Ë Tag ¤È¤¤¤¦ÀßÄêÍ󤬤¢¤ê¤Þ¤¹¡£


Tag



¡¡¸½ºß¤Ï Untagged (Tag ¤Ï̤ÀßÄê)¤Î¾õÂ֤ˤʤäƤ¤¤Þ¤¹¤Î¤Ç¡¢¤³¤ÎÉôʬ¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£
¥×¥ë¥À¥¦¥ó¥á¥Ë¥å¡¼¤¬³«¤¤¤Æ¡¢ÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë Tag ¤ÎÃ椫¤é£±¤Ä¤òÁªÂò¤·¤ÆÅÐÏ¿¤Ç¤­¤ë¾õÂ֤ˤʤê¤Þ¤¹¡£

¡¡Bullet ÍѤΠTag ¤Ï¤Þ¤ÀÅÐÏ¿¤·¤Æ¤¤¤Þ¤»¤ó¤Î¤Ç¡¢¥×¥ë¥À¥¦¥ó¥á¥Ë¥å¡¼¤Î°ìÈÖ²¼¤Ë¤¢¤ë Add Tags... ¥Ü¥¿¥ó¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤ÎÆâÍƤ¬¡¢Tags and Layers ¤È¤¤¤¦ÅÐÏ¿ÍѤÎÆâÍƤËÀÚ¤êÂؤï¤ê¤Þ¤¹¡£



¡¡Tag ¤ÎÅÐÏ¿¤Ï°ìÈÖ¾å¤Î Tags ÃʤǹԤ¤¤Þ¤¹¡£±¦²¼¤Ë¥×¥é¥¹¥Ü¥¿¥ó¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢²¡¤·¤Æ¤¯¤À¤µ¤¤¡£
Tag ¤òÅÐÏ¿¤·¤Æ¥»¡¼¥Ö¤ò¹Ô¤¦¤¿¤á¤Î¾®¤µ¤¤¥¦¥¤¥ó¥É¥¦¤¬³«¤­¤Þ¤¹¤Î¤Ç Bullet ¤ÈÆþÎϤ·¤Æ¥»¡¼¥Ö¤ò¤·¤Æ¤¯¤À¤µ¤¤¡£


Tag ¤ÎÅÐÏ¿



¡¡¤³¤Î¤È¤­¡¢¤³¤ÎÅÐÏ¿¤·¤¿Ê¸»úÎó¤Î¾ðÊó¤ò¡¢¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤¹¤ëÆâÍƤȹçÃפµ¤»¤Þ¤¹¡£
Âçʸ»ú¡¦¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤Þ¤¹¤Î¤Ç¡¢¥¹¥¯¥ê¥×¥È¤È Tag ¤Î½ñ¼°¤ò¹ç¤ï¤»¤ë¤³¤È¤¬ÂçÀڤǤ¹¡£



¡¡Tag ¤ÎÅÐÏ¿¤¬½ªÎ»¤·¤¿¤éºÆÅÙ¡¢Bullet ¤Î¥×¥ì¥Õ¥¡¥Ö¡¦¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÁªÂò¤· Open Prefab ¤·¤ÆÊÔ½¸¥â¡¼¥É¤Ë¤·¤Þ¤¹¡£
Àè¤Û¤É¤ÈƱ¤¸¤è¤¦¤Ë Tag ¤ÎÉôʬ¤ò¥¯¥ê¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£ÅÐÏ¿¤·¤¿ Buulet ¤Î Tag ¤¬ÁªÂò¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢ÅÐÏ¿¤·¤Þ¤¹¡£

¡¡¤³¤ì¤Ç Tag ¤ÎÀßÄê¤Ï´°Î»¤Ç¤¹¡£


¥×¥ì¥Õ¥¡¥Ö¤Î Buulet ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¡¡¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü



£¶¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¿¯ÆþȽÄê¤ÎºÝ¤Ë¡¢¿¯Æþ¤·¤¿¥³¥é¥¤¥À¡¼¤¬¥Ð¥ì¥Ã¥È¤Î¥³¥é¥¤¥À¡¼¤«¤É¤¦¤«¤òȽÄꤹ¤ë½èÍý¤òÄɲ乤ë


¡¡OnTriggerEnter2D ¥á¥½¥Ã¥É¤Ë¤Ï Collier ·¿¤Î°ú¿ô¤¬¤¢¤ê¡¢¿¯Æþ¤·¤Æ¤­¤¿¥³¥é¥¤¥À¡¼¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¥Ð¥ì¥Ã¥È¤Î¥³¥é¥¤¥À¡¼¤¬¿¯Æþ¤·¤¿¤é¡¢¤È¤¤¤¦¾ò·ï¤Ï¡¢¿¯Æþ¤·¤Æ¤­¤¿¥³¥é¥¤¥À¡¼¤Î¾ðÊó¤òÀººº¤¹¤ë¤³¤È¤¬½ÐÍè¤ì¤Ð¡¢¾ò·ï¤È¤·¤ÆÀ®Î©¤µ¤»¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£



¡¡Collier ·¿¤Î¾ðÊó¤Ï¹­¤¯³èÍѤ¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

¡¡Collier ·¿¤«¤é¤Ï¡¢¤½¤Î¥³¥é¥¤¥À¡¼¤Î¥¢¥¿¥Ã¥Á¤µ¤ì¤Æ¤¤¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬²Äǽ¤Ë¤Ê¤Ã¤Æ¤ª¤ê¡¢
¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬½ÐÍè¤ì¤Ð¡¢¤½¤³¤«¤é Tag ¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬²Äǽ¤Ç¤¹¡£
¤Ä¤Þ¤ê¡¢¿¯Æþ¤·¤Æ¤­¤¿¥³¥é¥¤¥À¡¼¤Î¾ðÊ󤬤狼¤ì¤Ð¡¢Tag ¤Î¾ðÊó¤ò¼èÆÀ¤·¤ÆÍøÍѤǤ­¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£


¡¡°Ê¾å¤ÎÀ߷פò¤Õ¤Þ¤¨¤Æ¡¢ºÇ½é¤Ë OnTriggerEnter2D ¥á¥½¥Ã¥É¤Ë¥í¥¸¥Ã¥¯¤Î¥³¥á¥ó¥È¤ò½ñ¤¤¤Æ¤ß¤Þ¤·¤ç¤¦¡£

¡ã¥³¥á¥ó¥È¤Î»²¹ÍÎã¡ä
  // ¿¯ÆþȽÄê
  private void OnTriggerEnter2D(Collider2D col) {

 ¡¡¡¡// ¿¯Æþ¤·¤¿¥³¥é¥¤¥À¡¼¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î Tag ¤¬ Bullet ¤Ê¤é¡Ê¤Ä¤Þ¤ê¡¢¤½¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ï Bullet ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ç¤¢¤ë¤ÈȽÄê¤Ç¤­¤ë¡Ë
  ¡¡ // ¤¢¤ë¤¤¤Ï¡¢Enemy ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤Ë¡¢Bullet ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤¬¿¯Æþ¤·¤Æ¤¤¤¿¤é¡¢¤È¤â½ñ¤±¤ë
            

     // ¿¯ÆþȽÄê¤Î³Îǧ

    }

¡¡¤É¤Î¤è¤¦¤Ë¤¹¤ì¤ÐÀ©¸æ¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ë¤Î¤«¡¢¹Í¤¨¤Æ½èÍý¤òµ­½Ò¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¤Þ¤¿ Debug.Log ¥á¥½¥Ã¥É¤Çɽ¼¨¤¹¤ëÆâÍƤ⡢Tag ¤Î̾Á°¤òɽ¼¨¤¹¤ë¤è¤¦¤ËÊѹ¹¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£


EnemyController.cs


¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¡¢Ëº¤ì¤º¤Ë¥»¡¼¥Ö¤·¤Þ¤·¤ç¤¦¡£¥·¥ç¡¼¥È¥«¥Ã¥È¥­¡¼¤ò³èÍѤ·¤Æ¤¯¤À¤µ¤¤¡£


£·¡¥¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¤½¤ì¤Ç¤Ï¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¡¢¥Ð¥ì¥Ã¥È¤È¥¨¥Í¥ß¡¼¤òÀÜ¿¨¤µ¤»¤Æ¤ß¤Þ¤¹¡£
Tag ¤Ë¤è¤Ã¤Æ¾ò·ï¤¬È½Äꤵ¤ì¤Þ¤¹¤Î¤Ç¡¢Bullet Tag ¤òÀßÄꤷ¤Æ¤¤¤ë¡¢¥Ð¥ì¥Ã¥È¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¤ß¾ò·ï¤òËþ¤¿¤¹¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
¤½¤Î¤È¤­¤Ï¡¢Debug.Log ¥á¥½¥Ã¥É¤¬¼Â¹Ô¤µ¤ì¤Æ¡¢"Bullet" ¤È¤¤¤¦ Tag ¤Î̾Á°¤¬ Console ¥Ó¥å¡¼¤Ëɽ¼¨¤µ¤ì¤Þ¤¹¡£


¡ã¼Â¹ÔÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯


¡¡¤â¤·¤â¿¯Æþ¤·¤¿È½Ä꤬¹Ô¤ï¤ì¤º¤Ë¡¢Console ¥Ó¥å¡¼¤Ë²¿¤âɽ¼¨¤µ¤ì¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢Tag ¤Îʸ»úÎó¤È¡¢¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤·¤¿ Tag ÍѤÎʸ»úÎó¤¬Æ±¤¸Ê¸»úÎó¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤«¤ò³Îǧ¤·¤Þ¤¹¡£
¤É¤Á¤é¤«¤ÎÀèƬ¤Îʸ»ú¤¬Âçʸ»ú¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ç¤¢¤ì¤Ð¡¢Âбþ¤¹¤ë¦¤Îʸ»úÎó¤â¡¢ÀèƬ¤Îʸ»ú¤¬Âçʸ»ú¤Ç¤Ê¤±¤ì¤Ð¤Ê¤ê¤Þ¤»¤ó¡£

¡¡Tag ¤ÎÅÐÏ¿¤¬ Bullet ¤Ç¤¢¤ë¤Ê¤é¡¢¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤¹¤ëʸ»úÎó¤â Bullet ¤Ë¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£



¡¡¤Þ¤¿ Enemy ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥ÈƱ»Î¤âÀÜ¿¨¤µ¤»¤Æ¡¢¿¯ÆþȽÄê¤Î·ë²Ì¤ò³Îǧ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¤³¤Á¤é¤â Tag ¤Ë¤è¤ëÀ©¸æ¤Ë¤è¤Ã¤Æ if ʸ¤Î½èÍý¤¬¼Â¹Ô¤µ¤ì¤Ê¤¤¤¿¤á¡¢if ʸÆâ¤Î½èÍý¤Ï¼Â¹Ô¤µ¤ì¤Þ¤»¤ó¡£
¤½¤Î¤¿¤á¡¢Debug.Log¥á¥½¥Ã¥É¤Ï¼Â¹Ô¤µ¤ì¤º¡¢Console ¥Ó¥å¡¼¤Ë¤â¥á¥Ã¥»¡¼¥¸¤¬É½¼¨¤µ¤ì¤Ê¤¤¤Ï¤º¤Ç¤¹¡£


¡ã¼Â¹ÔÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯


¡¡Ìµ»ö¤ËÀ©¸æ¤¬¤Ç¤­¤Þ¤·¤¿¤é¡¢¼¡¤Ï¡¢¥Ð¥ì¥Ã¥È¤Ë¿¯Æþ¤µ¤ì¤¿¥¨¥Í¥ß¡¼¤È¡¢¥Ð¥ì¥Ã¥È¼«ÂΤȤòÇ˲õ¤¹¤ëÀ©¸æ¤òÄɲ䷤Ƥ¤¤­¤Þ¤¹¡£


£²£±¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¿¯ÆþȽÄê¤ÎºÝ¤Ë¥¨¥Í¥ß¡¼¤È¥Ð¥ì¥Ã¥ÈξÊý¤òÇ˲õ¤¹¤ë½èÍý¤òÄɲ乤ë

£±¡¥Àß·×


¡¡¿¯ÆþȽÄê¤Ï OnTriggerEnter2D ¥á¥½¥Ã¥É¤ò¼ÂÁõ¤¹¤ë¤³¤È¤Ë¤è¤Ã¤ÆÆ°ºî¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤Î½èÍý¤ÎÃæ¤Ë¡¢¥Ð¥ì¥Ã¥È¤Î¥³¥é¥¤¥À¡¼¤¬¥¨¥Í¥ß¡¼¤Î¥³¥é¥¤¥À¡¼¤Ë¿¯Æþ¤·¤¿¤È¤­¤Ë¡¢¤É¤Á¤é¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤âÇ˲õ¤µ¤ì¤ë¤è¤¦¤ËÀ©¸æ¤ò¹Í¤¨¤Þ¤¹¡£
¡¡¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤¹¤ë½èÍý¤Ï¡¢Unity ¤ÎÍÑ°Õ¤·¤Æ¤¤¤ë Destroy ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç¼ÂÁõ¤Ç¤­¤Þ¤¹¡£
Destroy ¥á¥½¥Ã¥É¤Ç¤Ï¡¢Âè1°ú¿ô¤Ë»ØÄꤷ¤¿¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£

¡¡¤¤¤Þ¤Þ¤Ç¤ÈƱ¤¸¤è¤¦¤Ë¡¢¥í¥¸¥Ã¥¯¤ò¹Í¤¨¤ëºÝ¤Ë¤Ï¡¢ÆüËܸì¤Î¥³¥á¥ó¥È¤ò½ñ¤¤¤Æ¤ª¤¤¤Æ¡¢½èÍý¤ò¹Í¤¨¤Æ¤¤¤­¤Þ¤¹¡£


¡ã¥³¥á¥ó¥È¤Î»²¹ÍÎã¡ä
  // ¿¯ÆþȽÄê
  private void OnTriggerEnter2D(Collider2D col) {

¡¡¡¡¡¡¡¡// ¿¯Æþ¤·¤¿¥³¥é¥¤¥À¡¼¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î Tag ¤¬ Bullet ¤Ê¤é¡¡=>¡¡Enemy ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤Ë¡¢Bullet ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥³¥é¥¤¥À¡¼¤¬¿¯Æþ¤·¤Æ¤¤¤¿¤é
        if (col.gameObject.tag == "Bullet") {
            
            // ¿¯ÆþȽÄê¤Î³Îǧ
            Debug.Log("¿¯Æþ¤·¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¿¥°Ì¾ : " + col.gameObject.tag);


¡¡¡¡¡¡¡¡¡¡¡¡// ¥Ð¥ì¥Ã¥È¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤¹¤ë


            // ¥¨¥Í¥ß¡¼¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤¹¤ë


        }
    }

¡¡¤É¤Î¤è¤¦¤Ë¤¹¤ì¤ÐÀ©¸æ¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ë¤Î¤«¡¢¹Í¤¨¤Æ½èÍý¤òµ­½Ò¤·¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¥Ð¥ì¥Ã¥È¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢Debug.Log ¥á¥½¥Ã¥É¤Î°ú¿ô¤Îµ­½Ò¤ò»²¹Í¤·¤Æ¤¯¤À¤µ¤¤¡£


£²¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥Ð¥ì¥Ã¥È¤¬¥¨¥Í¥ß¡¼¤ËÀÜ¿¨¤·¤¿¤éÇ˲õ¤¹¤ë½èÍý¤òÄɲ乤ë


¡¡°Ê¾å¤ÎÀ߷פò¸µ¤Ë¡¢¼«Ê¬¤Ç¹Í¤¨¤Æ½èÍý¤ò½ñ¤¤¤Æ¤ß¤Þ¤·¤ç¤¦¡£
ÊÑ¿ô¤ÎÃÍ(Ãæ¤Î¾ðÊó)¤ò¤·¤Ã¤«¤ê¤ÈÍý²ò¤Ç¤­¤Æ¤¤¤ë¤«¤É¤¦¤«¤¬¡¢½èÍý¤òµ­½Ò¤¹¤ëºÝ¤Î¥Ý¥¤¥ó¥È¤Ë¤Ê¤ê¤Þ¤¹¡£


EnemyController.cs


¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¡¢Ëº¤ì¤º¤Ë¥»¡¼¥Ö¤ò¹Ô¤¤¤Þ¤·¤ç¤¦¡£


£³¡¥¥²¡¼¥à¤ò¼Â¹Ô¤·¤ÆÆ°ºî¤ò³Îǧ¤¹¤ë


¡¡¥¹¥¯¥ê¥×¥È¤Î½¤Àµ¤¬´°Î»¤·¤¿¤é¡¢¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¡¢¥Ð¥ì¥Ã¥È¤È¥¨¥Í¥ß¡¼¤Ë¤Ö¤Ä¤±¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
¥Ð¥ì¥Ã¥È¤È¥¨¥Í¥ß¡¼¤ÎξÊý¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤¬Ç˲õ¤µ¤ì¤ì¤Ð¡¢Ç˲õ½èÍý¤ÎÀ©¸æÀ®¸ù¤Ç¤¹¡£

¡ã¼Â¹ÔÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯

¡¡
¡¡¤â¤·¤â¾å¼ê¤¯Ç˲õ¤µ¤ì¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢Destroy ¥á¥½¥Ã¥É¤Î½èÍý¤Î¾ì½ê¤ä¡¢°ú¿ô¤Ë¤·¤Æ¤¤¤ë¾ðÊó¤ò¸«Ä¾¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£


£´¡¥¡ã½èÍý¤Î¥á¥½¥Ã¥É²½¡¡¡Ý¿·¤·¤¤¥á¥½¥Ã¥É¤ò£±¤ÄºîÀ®¤·¡¢OnTriggerEnter2D ¥á¥½¥Ã¥ÉÆâ¤Î½èÍý¤ÎÆâÍƤΰìÉô¤ò°ÜÆ°¤¹¤ë¡¼¡ä


¡¡½èÍý¤ò½ñ¤¤¤¿¸å¤Ë¤Ï¸«Ä¾¤·¤ò¹Ô¤¤¤Þ¤¹¡£

¡¡OnTriggerEnter2D ¥á¥½¥Ã¥ÉÆâ¤Ëµ­½Ò¤·¤¿½èÍý¤¬Ä¹¤¯¤Ê¤Ã¤Æ¤­¤¿¤Î¤Ç¡¢¿·¤·¤¯¥á¥½¥Ã¥É¤òºîÀ®¤·¡¢¤³¤Á¤é¤Î½èÍý¤ò¤½¤Î¥á¥½¥Ã¥ÉÆâ¤Ç½èÍý¤¹¤ë¤è¤¦¤Ë
¥¹¥¯¥ê¥×¥È¤Î½èÍý¤òºî¤êľ¤·¤Þ¤·¤ç¤¦¡£

¡¡¥Ç¥Ð¥Ã¥°¤È¤Ï°Û¤Ê¤ê¡¢½èÍý¤Îή¤ì¼«ÂΤËÊѹ¹¤Ï¤Ê¤¤¤â¤Î¤Î¡¢½èÍý¤ò¥á¥½¥Ã¥Éñ°Ì¤Ç¤Þ¤È¤á¤¿¤ê¡¢¸«¤ä¤¹¤¯¤·¤Æ²þÁ±¤¹¤ë¼êË¡¤ò¥ê¥Õ¥¡¥¯¥¿¥ê¥ó¥°¤È¤¤¤¤¤Þ¤¹¡£


    // ¿¯ÆþȽÄê
    private void OnTriggerEnter2D(Collider2D col) {

¡¡¡¡¡¡¡¡// ¥Ð¥ì¥Ã¥È¤¬ÀÜ¿¨¤·¤¿¤é
        if (col.gameObject.tag == "Bullet") {
     

////*  ¤³¤³¤«¤éÊ̤Υ᥽¥Ã¥É¤Ë½èÍý¤òµ­½Ò¤¹¤ë  *////

       
            // ¿¯ÆþȽÄê¤Î³Îǧ
            Debug.Log("¿¯Æþ¤·¤¿¥ª¥Ö¥¸¥§¥¯¥È̾ : " + col.gameObject.tag);

            // ¥Ð¥ì¥Ã¥È¤òÇ˲õ¤¹¤ë
            Destroy(col.gameObject);

            // ¤³¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÇ˲õ¤¹¤ë
            Destroy(gameObject);


////*  ¤³¤³¤Þ¤Ç  *////


        }
    }

¡¡º£²ó¤Ï¤³¤ÎÈϰϤνèÍý¤ò¿·¤·¤¯ºîÀ®¤¹¤ë¥á¥½¥Ã¥ÉÆâ¤Ë°ÜÆ°¤µ¤»¤Æ¡¢¤³¤ÎÉôʬ¤Ç¤Ï¡¢¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·Ì¿Îá¤Î¤ß¤òµ­½Ò¤¹¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£



¡¡º£²ó¥á¥½¥Ã¥É¤òºîÀ®¤·¤Æ½èÍý¤ò¹Ô¤¦¤¿¤á¤Ë¤Ï£±¤Ä¾ò·ï¤¬¤¢¤ê¤Þ¤¹¡£¤½¤ì¤Ï¡¢OnTriggerEnter2D ¥á¥½¥Ã¥É¤Ë¤ª¤¤¤Æ¼èÆÀ¤·¤Æ¤¤¤ë¡¢¿¯Æþ¤·¤Æ¤­¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Î¾ðÊó¤Ç¤¹¡£
¤³¤Î¾ðÊó¤Ï°ú¿ô¤Î col ÊÑ¿ô¤ËÂåÆþ¤µ¤ì¤Æ¤¤¤ë¾ðÊó¤Ç¤¢¤ë¤¿¤á¡¢Ê̤Υ᥽¥Ã¥É¤Ç¤Ï¥¹¥³¡¼¥×¤Î´Ø·¸¾åÍøÍѤǤ­¤Þ¤»¤ó¡£

¡¡¤½¤Î¤¿¤á¡¢Ê̤Υ᥽¥Ã¥É¤Ç¤³¤Î col ÊÑ¿ô¤Î¾ðÊó¤òÍøÍѤ¹¤ë¤Ë¤Ï¡¢¿·¤·¤¯ºîÀ®¤¹¤ë¥á¥½¥Ã¥É¤Ë¤â°ú¿ô¤òÍÑ°Õ¤·¤Æ¡¢¤³¤Î¾ðÊó¤òÅϤ·¤Æ¤¢¤²¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¡¡ÍÑ°Õ¤¹¤ë°ú¿ô¤Î·¿¤Ï¡¢Collier ·¿¡¢¤¢¤ë¤¤¤Ï GameObject ·¿¤Ç¤¢¤ì¤ÐÅϤ·¤ä¤¹¤¯¡¢¼õ¤±¼è¤Ã¤¿¥á¥½¥Ã¥É¤Ç¤âÍøÍѤ·¤ä¤¹¤¤¤Ç¤¹¡£

¡¡¼ÂºÝ¤Ë¼«Ê¬¤Ç½èÍý¤ò½ñ¤¤¤Æ¤ß¤Æ¤«¤é¡¢¤³¤Á¤é¤ò³Îǧ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£


EnemyController.cs


¡¡¤¤¤«¤¬¤Ç¤·¤ç¤¦¤«¡£
¥á¥½¥Ã¥É¤Ë°ìÏ¢¤Î½èÍý¤¬¤Þ¤È¤Þ¤Ã¤Æ¤ª¤ê¡¢¤Þ¤¿¡¢OnTriggerEnter2D ¥á¥½¥Ã¥ÉÆâ¤Î½èÍý¤â¥·¥ó¥×¥ë¤Ë¸«¤ä¤¹¤¯¤Ê¤Ã¤¿¤È»×¤¤¤Þ¤¹¡£

¡¡½èÍý¼«ÂΤÏƱ¤¸¤³¤È¤ò¹Ô¤Ã¤Æ¤¤¤ë¤Î¤Ç¤¹¤¬¡¢¤³¤Î¤è¤¦¤Ë½ñ¤­Êý¤òÊѤ¨¤ë¤À¤±¤Ç¡¢Á´ÂΤθ«¤ä¤¹¤µ¤âÊѤï¤Ã¤Æ¤­¤Þ¤¹¡£
³Ð¤¨¤Æ¤ª¤¤¤Æ¡¢¼«Ê¬¤Ç½èÍý¤ò½ñ¤¤¤¿ºÝ¤Ë¤Ï¡¢¸«Ä¾¤·¤ò¤·¤Æ¤¤¤¯¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£


¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£

¡¡¼¡¤Ï¡¡¼ê½ç£±£±¡¡¡Ý¥Ð¥ì¥Ã¥È¤Î¾ðÊó¤òÍøÍѤ·¤Æ¥¨¥Í¥ß¡¼¤òÇ˲õ¤¹¤ëÀ©¸æ¤ò¼ÂÁõ¡Ý¡¡¤Ç¤¹¡£

¥³¥á¥ó¥È¤ò¤«¤¯


¡Öhttp://¡×¤ò´Þ¤àÅê¹Æ¤Ï¶Ø»ß¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

ÍøÍѵ¬Ìó¤ò¤´³Îǧ¤Î¤¦¤¨¤´µ­Æþ²¼¤µ¤¤

Menu


´ðÁÃ

µ»½Ñ/Ãμ±(¼ÂÁõÎã)

3D¥¢¥¯¥·¥ç¥ó¥²¡¼¥à

2D¤ª¤Ï¤¸¤­¥²¡¼¥à(ȯŸÊÔ)

2D¶¯À©²£¥¹¥¯¥í¡¼¥ë¥¢¥¯¥·¥ç¥ó(ȯŸÊÔ)

2D¥¿¥Ã¥×¥·¥å¡¼¥Æ¥£¥ó¥°(³ÈÄ¥ÊÔ)

¥ì¡¼¥¹¥²¡¼¥à(È´¿è)

2DÊüÃÖ¥²¡¼¥à(ȯŸÊÔ)

3D¥ì¡¼¥ë¥¬¥ó¥·¥å¡¼¥Æ¥£¥ó¥°(±þÍÑÊÔ)

3Dæ½Ð¥²¡¼¥à(È´¿è)

2D¥ê¥¢¥ë¥¿¥¤¥à¥¹¥È¥é¥Æ¥¸¡¼

3D¥¿¥Ã¥×¥¢¥¯¥·¥ç¥ó(NavMeshAgent »ÈÍÑ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥«¥¨¥ë¤Î°Ù¤Ë¡Á¡¢¥Ü¥³¥¹¥«¥¦¥©¡¼¥ºÉ÷)

VideoPlayer ¥¤¥Ù¥ó¥ÈϢư¤Î¼ÂÁõÎã

VideoPlayer ¥ê¥¹¥ÈÆ⤫¤é¥à¡¼¥Ó¡¼ºÆÀ¸¤Î¼ÂÁõÎã(ȯŸ)

AR ²èÁüÉÕ¤­¥ª¥Ö¥¸¥§¥¯¥ÈÀ¸À®¤Î¼ÂÁõÎã

AR ¥ê¥¹¥ÈÆ⤫¤éÀ¸À®¤Î¼ÂÁõÎã(ȯŸ)

2D¥È¥Ã¥×¥Ó¥å¡¼¥¢¥¯¥·¥ç¥ó(¥µ¥Ð¥¤¥Ð¡¼É÷)

private



¤³¤Î¥µ¥¤¥ÈÆâ¤ÎºîÉʤϥæ¥Ë¥Æ¥£¤Á¤ã¤ó¥é¥¤¥»¥ó¥¹¾ò¹à¤Î¸µ¤ËÄ󶡤µ¤ì¤Æ¤¤¤Þ¤¹¡£

´ÉÍý¿Í/Éû´ÉÍý¿Í¤Î¤ßÊÔ½¸¤Ç¤­¤Þ¤¹