ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2023ǯ05·î15Æü(·î) 10:42:42ÍúÎò
¤³¤Î¼ê½ç¤Ç¤Ï̤¼ÂÁõ¤Ç¤¢¤Ã¤¿¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍÑ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ¤â¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ËÅÐÏ¿¤·¡¢¥¨¥Í¥ß¡¼¤´¤È¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÀßÄê¤ò¼«Æ°Åª¤Ë¹Ô¤¦µ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡°Ê²¼¤ÎÆâÍƤǽçÈ֤˼ÂÁõ¤ò¿Ê¤á¤Æ¤¤¤¤Þ¤¹¡£
ȯŸ£µ¡¡¡Ý¥¨¥Í¥ß¡¼¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¼«Æ°ÀßÄ굡ǽ¤Î¼ÂÁõ¡Ý
¡¡£¹¡¥³Æ¥¨¥Í¥ß¡¼¤´¤È¤Î°ÜÆ°ÍѤΥ¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë £±£°¡¥EnemyDataSO ¥¹¥¯¥ê¥×¥È¤È EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¨¥Í¥ß¡¼ÍѤΥץì¥Õ¥¡¥Ö¤Ë EnemyDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ç¡¼¥¿¤ò»²¾È¤·¤Æ¥¨¥Í¥ß¡¼Ëè¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òÀßÄꤹ¤ë½èÍý¤òÄɲ乤ë
¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£
¡¡¡¦AnimatorOverrideController ¥¯¥é¥¹
¡¡¥¨¥Í¥ß¡¼¤Î°ÜÆ°¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Ë¤Ï Blend Tree ¤Îµ¡Ç½¤òÍøÍѤ·¤Æ¡¢°ÜÆ°¤·¤Æ¤¤¤ëÊý¸þ¤Ë¹ç¤ï¤»¤Æ£´¼ïÎà¤Î¸þ¤¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òƱ´ü¤µ¤»¤Æ¤¤¤Þ¤¹¡£
¤³¤Î Blend Tree ¤Ë¤è¤ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÁ«°Ü¤µ¤»¤ë¾ðÊó¤ò¤½¤Î¤Þ¤ÞÍøÍѤ·¤Ä¤Ä¡¢£´Êý¸þ¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤À¤±¤ò³Æ¥¨¥Í¥ß¡¼¤Î AnimationClip ¤ËÊѹ¹¤¹¤ëµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¡¡¤³¤ì¤Ï Unity ¤¬ÍÑ°Õ¤·¤Æ¤¤¤ë AnimatorOverrideController ¤òÍøÍѤ¹¤ë¤³¤È¤Ç¼ÂÁõ½ÐÍè¤Þ¤¹¡£
¡¡¤½¤Î¤¿¤á¤Î½àÈ÷¤ò½çÈ֤˹ԤäƤ¤¤¤Þ¤¹¡£
¡¡°ÊÁ°¤Ë³Ø½¬¤·¤¿¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍÑ¥¹¥×¥é¥¤¥È¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òÀ½ºî¤¹¤ë¼ê½ç¤ò»²¹Í¤Ë¤·¤Æ¡¢
³Æ¥¨¥Í¥ß¡¼¤´¤È¤Ë£´Êý¸þʬ¤Î°ÜÆ°¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò AnimationClip ¤È¤·¤ÆºîÀ®¤·¤Þ¤¹¡£
¡¡¥¨¥Í¥ß¡¼¤´¤È¤Ë¥Õ¥©¥ë¥À¤òºîÀ®¤·¤Æ´ÉÍý¤ò¤¹¤ë¤È¤ï¤«¤ê¤ä¤¹¤¤¤Ç¤¹¡£
¤Þ¤¿¡¢EnemyData ¤Î¥¨¥Í¥ß¡¼¤ÎÄ̤·ÈÖ¹æ¤È¥Õ¥¡¥¤¥ë¤Î̾Á°¤â¥ê¥ó¥¯¤·¤Æ¤ª¤¯¤È¤ï¤«¤ê¤ä¤¹¤¯¤Ê¤ê¤Þ¤¹¡£
¥Õ¥©¥ë¥À²èÁü
¡¡¤Ê¤ª¡¢¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë¤¿¤Ó¤Ë¡¢¿·¤·¤¤¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤È AnimatorController ¤âºîÀ®¤µ¤ì¤Þ¤¹¤¬¡¢¤½¤Á¤é¤ÏÍøÍѤ·¤Þ¤»¤ó¡£
AnimationClip ¤ò£´Êý¸þʬ¤À¤±ºî¤Ã¤¿¤é¡¢°ì½ï¤ËºîÀ®¤µ¤ì¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤È AnimatorController ¤Ë¤Ä¤¤¤Æ¤Ïºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£
»²¹Í²èÁü¡Ê³Æ¥¨¥Í¥ß¡¼¤Î¥Õ¥©¥ë¥À¤òƱ¤¸¤è¤¦¤Ëºî¤ê¤Þ¤¹¡Ë
£³¡¥¥¨¥Í¥ß¡¼¤´¤È¤Ë AnimatorOverrideController ¤òºîÀ®¤·¤Æ¡¢¥Ù¡¼¥¹¤È¤Ê¤ë AnimatorController ¤È¡¢³Æ¥¨¥Í¥ß¡¼¤´¤È¤Î°ÜÆ°¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó(AnimationClip)¤òÅÐÏ¿¤¹¤ë
¡¡¤Þ¤º¤ÏºÇ½é¤Ë¡¢¸½ºßÍøÍѤ·¤Æ¤¤¤ë¥¨¥Í¥ß¡¼¤Î AnimatorController ¤Ç¤¹¤¬¡¢Ì¾¾Î¤ò Base_Enemy ¤ËÊѹ¹¤·¡¢EnemyBase ¥Õ¥©¥ë¥À¤Ø°ÜÆ°¤·¤Æ¤¯¤À¤µ¤¤¡£
¤³¤Î AnimatorController ¤ò¸µ¤Ë¤·¤Æ¡¢¤³¤ì¤«¤éºîÀ®¤¹¤ë AnimatorOverrideController ¤òÀßÄꤷ¤Æ¤¤¤¤Þ¤¹¡£
Base_Enemy
¡¡¼¡¤Ë¡¢³Æ¥¨¥Í¥ß¡¼¤Î°ÜÆ°ÍѤΥ¢¥Ë¥á¡¼¥·¥ç¥ó¤òÅÐÏ¿¤¹¤ë¤¿¤á¤Î AnimatorOverrideController ¤òºîÀ®¤·¤Þ¤¹¡£
¤³¤ì¤Ï¡¢³Æ¥¨¥Í¥ß¡¼¤Ë¤Ä¤¡¢£±¤Ä¤º¤ÄºîÀ®¤·¤Þ¤¹¡£
¡¡¤Þ¤º¤Ï Enemy_0 ¤Î¥Õ¥©¥ë¥ÀÆâ¤Ç±¦¥¯¥ê¥Ã¥¯¤ò¤·¤Æ¥á¥Ë¥å¡¼¤ò³«¤¡¢Create => AnimatorOverrideController ¤òÁªÂò¤·¤Æ¤¯¤À¤µ¤¤¡£
AnimatorController ¤Ë»÷¤¿¥¢¥¤¥³¥ó¤Î AnimatorOverrideController ¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£(¤³¤Á¤é¤Î¥¢¥¤¥³¥ó¤Ï±¦²¼¤Ë¥×¥é¥¹¥Þ¡¼¥¯¤¬¤¢¤ê¤Þ¤¹)
̾Á°¤Ï Enemy_0 ¤Î¤è¤¦¤Ë¡¢¥¨¥Í¥ß¡¼¤ÎÄ̤·ÈÖ¹æ¤Ë½à¤¸¤¿¥Õ¥¡¥¤¥ë̾¤Ë¤·¤Æ¤ª¤¯¤È¡¢º£¸å¡¢´ÉÍý¤·¤ä¤¹¤¯¤Ê¤ê¤Þ¤¹¡£
¡¡AnimatorOverrideController ¤Îµ¡Ç½¤È¤·¤Æ¤Ï¡¢Blend Tree ¤Ê¤É¤ÇºîÀ®¤·¤Æ¤¤¤ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÁ«°Ü¤Î¾ðÊó¤ò¤½¤Î¤Þ¤ÞÍøÍѤ·¡¢
ŬÍѤ¹¤ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÆâÍƤÀ¤±¤ò¾å½ñ¤¤·¤Æº¹¤·Âؤ¨¤ëµ¡Ç½¤òͤ·¤Æ¤¤¤Þ¤¹¡£
¡¡¤½¤Î¤¿¤á¡¢¸½ºß¥¨¥Í¥ß¡¼¤¬ÍøÍѤ·¤Æ¤¤¤ë Move ¥¹¥Æ¡¼¥ÈÆâ¤Î Blend Tree ¤Îµ¡Ç½¤Ï¤½¤Î¤Þ¤Þ¤Ç¡¢Blend Tree Æâ¤ÇÀßÄꤷ¤Æ¤¤¤ë³Æ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÆâÍƤΤߤò¾å½ñ¤¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¡ãMove ¥¹¥Æ¡¼¥È¤Î Motion ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë Blend Tree ¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÁ«°Ü¾ò·ï¤ò¤½¤Î¤Þ¤Þ»È¤¦¡ä
¡ã³ÆMotion ¤ò¤½¤ì¤¾¤ìÊ̤ÎÆâÍƤÇÅÐÏ¿¤Ç¤¤ë¡ä
»²¹Í¥µ¥¤¥È
Unity ¸ø¼°¥¹¥¯¥ê¥×¥È¡¦¥ê¥Õ¥¡¥ì¥ó¥¹
AnimatorOverrideController
¡¡¤½¤ì¤Ç¤ÏÁá®ÅÐÏ¿¤·¤Æ¤¤¤¤Þ¤¹¡£
¡¡Enemy_0 ¤Î AnimatorOverrideController ¤òÁªÂò¤·¤Æ¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤ò³Îǧ¤·¤Þ¤¹¡£
¡¡Controller ¤Î¹àÌܤˤϡ¢¥Ù¡¼¥¹¤È¤Ê¤ë¥¨¥Í¥ß¡¼¤Î AnimatorController ¤òÀßÄꤷ¤Þ¤¹¡£
¤³¤Á¤é¤Ë¤ÏÀè¤Û¤É̾¾Î¤òÊѹ¹¤·¤¿ EnemyBase ¥Õ¥©¥ë¥ÀÆâ¤Ë¤¢¤ë Base_Enemy ¤ò¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤Æ¥¢¥µ¥¤¥ó¤·¤Þ¤¹¡£
¤³¤ì¤Ç¥Ù¡¼¥¹¤È¤Ê¤ë AnimatorController ¤¬ÀßÄꤵ¤ì¤Þ¤·¤¿¡£¼«Æ°Åª¤Ë¡¢Blend Tree ¤ÎÃæ¤ÇÀßÄꤷ¤Æ¤¤¤ë£´¤Ä¤Î Motion ¤òÅÐÏ¿¤¹¤ë¤¿¤á¤Î¾ðÊó¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£
¡¡¤³¤Á¤é¤Ë¡¢£´Êý¸þʬ¤Î AnimationClip ¤ò¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤Æ¥¢¥µ¥¤¥ó¤·¤Æ¤¯¤À¤µ¤¤¡£
¤½¤ì¤Ç¥¨¥Í¥ß¡¼£±ÂÎʬ¤Î AnimatorOverrideController ¤¬´°À®¤Ç¤¹¡£
¡¡
¡¡¤³¤Î¼ê½ç¤ò¡¢¥¨¥Í¥ß¡¼¤Î¿ô¤À¤±·«¤êÊÖ¤·¤Æ¡¢¤¹¤Ù¤Æ¤Î¥¨¥Í¥ß¡¼¤Ë AnimatorOverrideController ¤òÍÑ°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü
¥Õ¥©¥ë¥À²èÁü
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü
¥Õ¥©¥ë¥À²èÁü
£±£°¡¥EnemyDataSO ¥¹¥¯¥ê¥×¥È¤È EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¨¥Í¥ß¡¼ÍѤΥץì¥Õ¥¡¥Ö¤Ë EnemyDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ç¡¼¥¿¤ò»²¾È¤·¤Æ¥¨¥Í¥ß¡¼Ëè¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òÀßÄꤹ¤ë½èÍý¤òÄɲ乤ë
¡¡EnemyDataSO ¥¹¥¯¥ê¥×¥ÈÆâ¤Ë¤¢¤ë EnemyData ¥¯¥é¥¹¤ò½¤Àµ¤·¡¢Àè¤Û¤ÉºîÀ®¤·¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òÅÐÏ¿¤¹¤ë¤¿¤á¤ÎÊÑ¿ô¤ò¿·¤·¤¯Äɲä·¤Þ¤¹¡£
¤½¤Î¸å¡¢EnemyController ¥¹¥¯¥ê¥×¥È¤Î½¤Àµ¤·¡¢EnemyData ¤Ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬¤¢¤ë¾ì¹ç¡¢¥¨¥Í¥ß¡¼¤´¤È¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Ë¾å½ñ¤¤¹¤ë½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£
£³¡¥EnemyDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ë³Æ¥¨¥Í¥ß¡¼¤´¤È¤ËºîÀ®¤·¤¿ AnimatorOverrideController ¤òÅÐÏ¿¤¹¤ë
¡¡Datas ¥Õ¥©¥ë¥ÀÆâ¤Ë¤¢¤ë EnemyDataSO ¥¹¥¯¥ê¥×¥È¤ò³Îǧ¤·¤Þ¤¹¡£
¿·¤·¤¯ EnemyData ¥¯¥é¥¹¤ËÄɲä·¤¿ enemyOverrideController ÊÑ¿ô¤¬É½¼¨¤µ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
¤³¤Á¤é¤Ë³Æ¥¨¥Í¥ß¡¼ÍѤ˺îÀ®¤·¤¿ AnimatorOverrideController ¤ò¤½¤ì¤¾¤ì¥¢¥µ¥¤¥ó¤·¤ÆÅÐÏ¿¤·¤Æ¤¯¤À¤µ¤¤¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü
¡¡ºÇ¸å¤Ë EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¤³¤Î enemyOverrideController ÊÑ¿ô¤Î¾ðÊó¤òÍøÍѤ·¤Æ¡¢¥¨¥Í¥ß¡¼¤Î°ÜÆ°¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Îº¹¤·Âؤ¨(¾å½ñ¤)¤¹¤ë½èÍý¤òÄɲä·¤Þ¤¹¡£
£´¡¥EnemyController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¨¥Í¥ß¡¼¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò EnemyData Æâ¤Ë¤¢¤ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¾ðÊó¤Ë¾å½ñ¤¤¹¤ë½èÍý¤òÄɲ乤ë
¡¡¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò¾å½ñ¤¤¹¤ë¤Ë¤Ï¡¢Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ËÂФ·¤Æ½èÍý¤ò¼Â¹Ô¤·¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¸½ºß SetUpEnemyController ¥á¥½¥Ã¥ÉÆâ¤Ç TryGetComponent ¥á¥½¥Ã¥É¤òÍøÍѤ·¤Æ Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò¼èÆÀ¤¹¤ëÉôʬ¤ò½¤Àµ¤·¡¢
Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î¼èÆÀ¤¬½ÐÍ褿¾ì¹ç¤Ë¤Ï¡¢¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò¾å½ñ¤¤¹¤ë¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤è¤¦¤Ëʬ´ô¤òºîÀ®¤·¤Þ¤¹¡£
¡¡¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¾å½ñ¤¤ò¹Ô¤¦ SetUpAnimation ¥á¥½¥Ã¥É¤Ç¤Ï¤Þ¤ººÇ½é¤Ë EnemyData Æâ¤Ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¾ðÊ󤬤¢¤ë¤«³Îǧ¤ò¹Ô¤¤¡¢Null ¤Ë¤è¤ë¥¨¥é¡¼¤òËɻߤ·¤Þ¤¹¡£
¤½¤Î¾å¤Ç¡¢Animetor ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤Î Controller ¤Î¾ðÊó¤ò AnimatorOverrideController ¤Î¾ðÊó¤Ë¾å½ñ¤¤·¤Æº¹¤·Âؤ¨¤·¤Þ¤¹¡£
¤³¤Î½èÍý¤¬¼ÂÁõ¤µ¤ì¤ë¤³¤È¤Ë¤è¤ê¡¢³Æ¥¨¥Í¥ß¡¼¤´¤È¤Ë°Û¤Ê¤ë°ÜÆ°¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬¼«Æ°Åª¤ËÀßÄꤵ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
EnemyController.cs
¡¡¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤¿¤é¥»¡¼¥Ö¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡¥²¡¼¥à¤ò¼Â¹Ô¤·¤Æ¡¢¥¨¥Í¥ß¡¼¤Ë±þ¤¸¤Æ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬º¹¤·Âؤ¨¤é¤ì¤Æ¤¤¤ë¤«¤ò³Îǧ¤·¤Þ¤¹¡£
¡¡À¸À®¤µ¤ì¤¿ Enemy ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤«¤é Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È Æâ¤Î Controller ¤¬ÊѲ½¤·¤Æ¤¤¤ë¤«¤ò³Îǧ¤·¤Æ¤ª¤¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü¡
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü¢
¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£
¡¡¼¡¤Ï¡¡È¯Å¸£¶¡¡¡Ý¥Ç¥Ð¥Ã¥°¥â¡¼¥Éµ¡Ç½¤Î¼ÂÁõ¡Ý¡¡¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯