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

¡¡¥Ý¥Ã¥×¥¢¥Ã¥×Æâ¤ÇÁªÂò¤·¤Æ¤¤¤ë¥­¥ã¥é¤ò¥¿¥¤¥ë¥Þ¥Ã¥×¤ËÇÛÃÖ¤¹¤ë½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£

¡¡¤³¤Î¼ê½ç¤¬´°À®¤¹¤ë¤³¤È¤Ç¡¢²¼µ­¤ÎÆ°²è¤Î¤è¤¦¤Ë¡¢¥Ý¥Ã¥×¥¢¥Ã¥×Æâ¤ÇÁªÂò¤·¤¿¥­¥ã¥é¤¬ÇÛÃÖ¤µ¤ì¤ëµ¡Ç½¤ò¼ÂÁõ¤·¤Þ¤¹¡£
¤¿¤À¤·¡¢ÇÛÃÖ¤·¤¿¥­¥ã¥é¤¬¥¢¥Ë¥á¡¼¥·¥ç¥ó¤»¤º¤Ë¡¢£±Ëç¤Î²èÁü¤Î¾õÂ֤Ǥ¢¤ë¾ì¹ç¤ÇÌäÂ꤬¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢¤³¤Î¼ê½ç¤ÏÉÔÍפǤ¹¡£

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


¡¡°Ê²¼¤ÎÆâÍƤǼÂÁõ¤ò¿Ê¤á¤Æ¤¤¤­¤Þ¤¹¡£

¼ê½ç£²£³¡¡¡¼ÇÛÃÖ¤·¤¿¥­¥ã¥é¤Î¥¢¥Ë¥á¤ò¼«Æ°ÀßÄꤹ¤ë½èÍý¤Î¼ÂÁõ¡¼
£´£±¡¥CharaController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢ÇÛÃÖ¤·¤¿¥­¥ã¥é¤Ë¹ç¤ï¤»¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºÆÀ¸¤¹¤ëµ¡Ç½¤ò¼ÂÁõ¤¹¤ë



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

¡¡¡¦AnimationClip ¤ÎưŪ¤Êº¹¤·Âؤ¨½èÍý



£±¡¥Àß·×


¡¡²èÌ̤ËÇÛÃÖ¤·¤¿¥­¥ã¥é¤Ï CharaData ¤Ë Sprite ²èÁü¤ÎÀßÄ꤬¤¢¤ë¤¿¤á¡¢¤½¤Î¾ðÊó¤ò»²¾È¤·¤Æ¡¢²èÁü¤¬ÊѤï¤ë¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡¤³¤Î¼ê½ç¤Ç¤Ï¤µ¤é¤Ë°ìÊâƧ¤ß¹þ¤ó¤Ç¡¢³Æ¥­¥ã¥é¤´¤È¤ËºîÀ®¤·¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¾ðÊó(AnimationClip)¤ò CharaData ¤È¤·¤ÆÀßÄê¤Ç¤­¤ë¤è¤¦¤Ë¤·¡¢
¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î¿¶¤ëÉñ¤¤¤òÊѤ¨¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£

¡¡¤½¤¦¤¹¤ë¤³¤È¤Ë¤è¤ê¡¢²èÌ̤ËÇÛÃÖ¤·¤¿¥­¥ã¥é¤Ï¡¢£±Ëç¤Î²èÁü¤Ç¤Ï¤Ê¤¯¡¢¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¹¤ë¾ðÊó¤â¥­¥ã¥é¤´¤È¤Ë»²¾È¤·¤ÆÀßÄê¤Ç¤­¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£


£²¡¥¥­¥ã¥é¤´¤È¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë


¡¡¼ê½ç£¹Æâ¤Ë¤¢¤ë¡Ú£±£´¡¥£²°ÜÆ°¥¢¥Ë¥á¤ÎºîÀ®¤ò¹Ô¤¦¡Û¤ò»²¹Í¤Ë¤·¤Ê¤¬¤é¡¢
³Æ¥­¥ã¥é¤Î¥¹¥×¥é¥¤¥È¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤·¤Þ¤¹¡£

¡¡ÀµÌ̤ò¸þ¤¤¤Æ¤¤¤ë¥¹¥×¥é¥¤¥È²èÁü¤òÍøÍѤ·¤Æ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤·¤Æ¤¯¤À¤µ¤¤¡£Ì¾Á°¤Ï Chara_1 ¤Î¤è¤¦¤Ë¡¢½ª¤ï¤ê¤Î¿ô»ú¤ÎÉôʬ¤òÏ¢È֤ˤ·¤Æ
CharaDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥ÈÆâ¤Î³Æ¥­¥ã¥é¤ÎÄ̤·ÈÖ¹æ¤Î¾ðÊó(CharaNo ÊÑ¿ô)¤ÈƱ¤¸ÈÖ¹æ¤Ë¤·¤Æ¤ª¤¯¤³¤È¤Ç´ÉÍý¤¬¤·¤ä¤¹¤¯¤Ê¤ê¤Þ¤¹¡£

¡¡¥¹¥×¥é¥¤¥È¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë¤È AnimationClip ¤Î¾¤Ë AnimatorController ¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£
¤³¤ì¤é¤ÏÉÔÍפǤ¹¤Î¤Ç¡¢AnimationClip ¤À¤±»Ä¤·¤Æ¡¢AnimatorController ¤Ïºï½ü¤·¤Æ¤¯¤À¤µ¤¤¡£

¡¡¥Õ¥©¥ë¥À¤Ê¤É¤â¼«Ê¬¤ÇºîÀ®¤·¤Æ¡¢¥Õ¥¡¥¤¥ë¤ÎÀ°ÍýÀ°Æܤò¿´¤¬¤±¤Æ¤¯¤À¤µ¤¤¡£


»²¹Í¡¡¥­¥ã¥éʬ¤Î AnimationClip¡£AnimatorController ¤ÏºÇ½é¤Ë¤¢¤ë¤â¤Î°Ê³°¤Ïºï½ü



¡¡Â³¤¤¤Æ¡¢¤³¤Î³Æ AnimationClip ¤ò CharaDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ËÅÐÏ¿¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë¤¿¤á¡¢CharaData ¥¯¥é¥¹¤Ë¾ðÊó¤òÄɵ­¤·¤Þ¤¹¡£


£³¡¥CharaData ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¾ðÊó¤òÅÐÏ¿¤Ç¤­¤ë¤è¤¦¤Ë¤¹¤ë


¡¡¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î¥Ç¡¼¥¿¤Ï¡¢¤³¤Î CharaData ¥¯¥é¥¹¤ò¸µ¤ËºîÀ®¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ë¿·¤·¤¤ÊÑ¿ô¤Î¾ðÊó¤òÄɲä·¤¿¤¤¾ì¹ç¤Ë¤Ï¡¢¤½¤Î¸µ¤Ç¤¢¤ë CharaData ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¤Æ¡¢¿·¤·¤¤ÊÑ¿ô¤òÄɲ乤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£


CharaData.cs

<= ¥¯¥ê¥Ã¥¯¤¹¤ë¤È³«¤­¤Þ¤¹


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


£´¡¥CharaDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ë³Æ¥­¥ã¥é¤´¤È¤Î AnimationClip ¤òÅÐÏ¿¤¹¤ë


¡¡CharaData ¥¯¥é¥¹¤Ë¿·¤·¤¤ÊÑ¿ô¤òÄɲä·¤Þ¤·¤¿¤Î¤Ç¡¢¥»¡¼¥Ö¤ò¹Ô¤¦¤È¡¢¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ÎÊý¤Ë¤â¼«Æ°Åª¤Ë¿·¤·¤¤¾ðÊó¤È¤·¤Æ CharaAnim ÊÑ¿ô¤¬Äɲ䵤ì¤Þ¤¹¡£
¿·¤·¤¤ÊÑ¿ô¤¬Äɲ䵤ì¤ë¤À¤±¤Ç°ÊÁ°¤Î¥Ç¡¼¥¿¤Ï»Ä¤Ã¤Æ¤¤¤Þ¤¹¡£

¡¡charaAnime ÊÑ¿ô¤Ë¤Ï¡Ú£²¡¥¥­¥ã¥é¤´¤È¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºîÀ®¤¹¤ë¡Û¤ÇºîÀ®¤·¤¿¥¹¥×¥é¥¤¥È¥¢¥Ë¥á¡¼¥·¥ç¥ó(AnimationClip ·¿)¤òÅÐÏ¿¤Ç¤­¤Þ¤¹¡£
¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤Æ¡¢³Æ¥­¥ã¥é¤´¤È¤Î AnimationClip ¤òÅÐÏ¿¤·¤Æ¤¯¤À¤µ¤¤¡£


CharaDataSO ¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¡¡¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü



¡¡°Ê¾å¤ÇÀßÄê¤Ï´°Î»¤Ç¤¹¡£ºÇ¸å¤Ë CharaController ¤ò½¤Àµ¤·¡¢¤³¤Î CharaAnim ÊÑ¿ô¤òÍøÍѤ·¤Æ¡¢ÇÛÃÖ¤µ¤ì¤¿¥­¥ã¥é¤Ë¹ç¤ï¤»¤Æ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òº¹¤·Âؤ¨¤ë½èÍý¤ò¼ÂÁõ¤·¤Þ¤¹¡£


£µ¡¥CharaController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤¹¤ë


¡¡¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÀßÄêÍѤÎÊÑ¿ô¤ÎÀë¸À¤È SetUpChara ¥á¥½¥Ã¥ÉÆâ¤Ç¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÀßÄêÍѤΠSetUpAnimation ¥á¥½¥Ã¥É¤Î¸Æ¤Ó½Ð¤·¤òµ­½Ò¤·¤Þ¤¹¡£
¤Ê¤ª¡¢SetUpAnimation ¥á¥½¥Ã¥ÉÆâ¤Î½èÍý¤Ï¡¢¥Æ¥é¥·¥å¡¼¥ë¥Ö¥í¥°ÍͤΥµ¥¤¥È¤Îµ­»ö¤ò»²¹Í¤Ë¤µ¤»¤Æ¤¤¤¿¤À¤¤¤Æ¤ª¤ê¤Þ¤¹¡£¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤¹¡£
¥Æ¥é¥·¥å¡¼¥ë¥Ö¥í¥° ÍÍ
¡ÚUnity¡ÛMecanim¤ÎAnimationClip¤òưŪ¤Ëº¹¤·Âؤ¨¤ë
http://tsubakit1.hateblo.jp/entry/2016/11/18/23413...



¡¡½èÍý¤ÎÆâÍƤȤ·¤Æ¤Ï¡¢AnimationClip ¤Îº¹¤·Âؤ¨¤ò¹Ô¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
Animator ¥Ó¥å¡¼¤Î¥¹¥Æ¡¼¥È¤òÁªÂò¤¹¤ë¤È Motion Éôʬ¤Ë AnimationClip ¤Î¾ðÊó¤¬É½¼¨¤µ¤ì¤Þ¤¹¡£¤³¤³¤ò¥²¡¼¥àÆâ¤ÇưŪ¤ËÊѹ¹¤ò¹Ô¤¤¤Þ¤¹¡£

¡¡¿·¤·¤¯ºîÀ®¤¹¤ë overrideClipName ÊÑ¿ô¤ËÅÐÏ¿¤¹¤ëʸ»úÎ󤬡¢º¹¤·Âؤ¨¤ë AnimationClip ¤ÈƱ̾¤Îʸ»úÎó¤Ç¤¢¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£
¤½¤Î¤¿¤á¤³¤ÎÊÑ¿ô¤ÎÃͤϡ¢¼«Ê¬¤Î¥×¥í¥¸¥§¥¯¥È¤ÎÆâÍƤ˹ç¤ï¤»¤ÆÊѹ¹¤¹¤ëɬÍפ¬¤¢¤ê¤Þ¤¹¡£

¡¡Chara ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î Animator ¥Ó¥å¡¼¤ò³Îǧ¤·¡¢Chara ¥¹¥Æ¡¼¥È¤òÁªÂò¤·¤Þ¤¹¡£¤³¤Î¤È¤­¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Î Motion Éôʬ¤Ë AnimationClip ¤Î̾Á°¤¬É½¼¨¤µ¤ì¤Þ¤¹¤Î¤Ç¡¢
¤½¤Î̾¾Î¤ò¤³¤ÎÊÑ¿ô¤ËÂåÆþ¤¹¤ë¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£¤½¤¦¤·¤Ê¤¤¤È¡¢¥­¥ã¥é¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òưŪ¤Ëº¹¤·Âؤ¨¤ë½èÍý¤¬¾å¼ê¤¯¼Â¹Ô¤µ¤ì¤Þ¤»¤ó¡£


Animator ¥Ó¥å¡¼¡¡¥¤¥ó¥¹¥Ú¥¯¥¿¡¼²èÁü



¡¡
CharaController.cs


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


£¶¡¥¡ãAnimationClip ¤ÎưŪ¤Êº¹¤·Âؤ¨½èÍý¡ä


¡¡º£²óÄɲä·¤¿ SetUpAnimation ¥á¥½¥Ã¥ÉÆâ¤Ç¤ä¤Ã¤Æ¤¤¤ë¤³¤È¤Ç¤¹¤¬¡¢¤³¤ì¤Ï¡¢²¼µ­¤Î¥Þ¥Ë¥å¥¢¥ë¤ò¸«¤Æ¤¤¤¿¤À¤¯¤È²Ä»ë²½¤Ç¤­¤Þ¤¹¡£
¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤ÇÀßÄê¤Ç¤­¤ë¤³¤È¤ò¡¢¥²¡¼¥àÆâ¤Ç¥é¥ó¥¿¥¤¥à¤ËÀ©¸æ¤¹¤ë¤¿¤á¡¢¥¹¥¯¥ê¥×¥È¤òÍøÍѤ·¤ÆƱ¤¸¤³¤È¤ò¤·¤Æ¤¤¤ë¥¤¥á¡¼¥¸¤Ç¤¹¡£
¡¡

Unity ¸ø¼°¥Þ¥Ë¥å¥¢¥ë
Animator Override Controller


¡¡¤½¤ì¤Ç¤Ï½èÍý¤ÎÆâÍƤò£±¹Ô¤º¤ÄÆɤ߲ò¤¤¤Æ¤¤¤­¤Þ¤¹¡£



overrideController = new AnimatorOverrideController();

overrideController.runtimeAnimatorController = anim.runtimeAnimatorController;

¡¡¿·¤·¤¯ AnimatorOverrideController ¤Î¥¤¥ó¥¹¥¿¥ó¥¹¤òºîÀ®¤·¡¢¤½¤Î runtimeAnimatorController ÊÑ¿ô¤Ë¡¢¸½ºß¤Î AnimatorController ¤Î runtimeAnimatorController ÊÑ¿ô¤òÂåÆþ¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤ì¤ÏÀè¤Û¤É¤Î¥Þ¥Ë¥å¥¢¥ë¤ò¸«¤Æ¤¤¤¿¤À¤¯¤È¤ï¤«¤ë¤Î¤Ç¤¹¤¬¡¢¾å½ñ¤­¤¹¤ëÊý¤Ë¤â¸½ºß¤ÈƱ¤¸¾ðÊó¤òÂåÆþ¤·¤Æ¤ª¤¯É¬Íפ¬¤¢¤ë¤¿¤á¤Ç¤¹¡£



anim.runtimeAnimatorController = overrideController;

¡¡¸½ºß¤Î AnimatorController ¤Î runtimeAnimatorController ¤ËÂФ·¤Æ¿·¤·¤¯ºîÀ®¤·¤¿ AnimatorOverrideController ¤òÂåÆþ¤·¤Æ¹¹¿·¤·¤Þ¤¹¡£
¤³¤Î»þÅÀ¤Ç¡¢°ìö¡¢¤Þ¤Ã¤¿¤¯Æ±¤¸ÆâÍƤξðÊó¤Ç¹¹¿·¤¬Æþ¤ê¤Þ¤¹¡£

¡¡¤³¤Î½èÍý¤ò¹Ô¤Ã¤Æ¤ª¤¯¤³¤È¤Ç¡¢AnimatorController ¤¬ºÆÀ¸½èÍý¤ò¹Ô¤¦¤È¤­¡¢AnimatorOverrideController ¤ÎÀßÄê¤òÍøÍѤ¹¤ë¤³¤È¤¬¤Ç¤­¤ë¾õÂ֤ˤʤê¤Þ¤¹¡£



AnimatorStateInfo[] layerInfo = new AnimatorStateInfo[anim.layerCount];

¡¡AnimatorStateInfo ·¿¤ÎÇÛÎó¤òÍÑ°Õ¤·¡¢anim.layerCount ÊÑ¿ô¤À¤±Í×ÁÇÈÖ¹æ¤ò¼èÆÀ¤·¤Æ¤ª¤­¤Þ¤¹¡£

¡¡´ðËÜŪ¤Ë anim.layerCount ¤ÎÃÍ¤Ï 1 ¤Ç¤¹¡£ÆâÍƤȤ·¤Æ¤Ï BaseLayer(¤¤¤Ä¤â¥¹¥Æ¡¼¥È¤òÅÐÏ¿¤·¤Æ¤¤¤ë¾ì½ê) ¤Î¾ðÊó¤Ë¤Ê¤ê¤Þ¤¹¡£
³Îǧ¤¹¤ë¤¿¤á¤Ë¤Ï¡¢11¹ÔÌÜ¤Ë Debug.Log("LayerCount : " + anim.layerCount ); ¤òÆþ¤ì¤Æ¤ß¤ë¤Èʬ¤«¤ê¤Þ¤¹¡£

¡¡²¿¤«ÆâÉôŪ¤Ê¾ðÊó¤ò²Ä»ë²½¤·¤Æ³Îǧ¤·¤¿¤¤¤È¤­¤Ë¤Ï¡¢Debug ¥¯¥é¥¹¤Î Log ¥á¥½¥Ã¥É¤ò³èÍѤ·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£



for (int i = 0; i < anim.layerCount; i++)
{
    //GetCurrentAnimatorStateInfo¤ÇAnimator¤Î¸½ºß¤Î¾õÂÖ¤«¤é¥Ç¡¼¥¿¤ò¼èÆÀ¤¹¤ë¡£Î㤨¤Ð¡¢Â®ÅÙ¡¢Ä¹¤µ¡¢Ì¾Á°¡¢¤½¤Î¾¤ÎÊÑ¿ô¤Ê¤É
    layerInfo[i] = anim.GetCurrentAnimatorStateInfo(i);  
}

¡¡GetCurrentAnimatorStateInfo ¥á¥½¥Ã¥É¤ò¼Â¹Ô¤¹¤ë¤³¤È¤Ç Animator ¤Î¸½ºß¤Î¾õÂÖ¤ò¼èÆÀ¤Ç¤­¤Þ¤¹¡£
¤½¤ì¤òÍÑ°Õ¤·¤Æ¤ª¤¤¤¿¶õ¤Î¾õÂ֤ΠlayerInfo ÇÛÎó¤ËÂåÆþ¤·¤ÆÊÝ»ý¤·¤Æ¤ª¤­¤Þ¤¹¡£

¡¡BaseLayer ¤·¤«¤Ê¤¤¾ì¹ç¡¢layerCount ÊÑ¿ô¤Ï 1 ¤Ê¤Î¤Ç¡¢¤³¤Î¥ë¡¼¥×¤Ï1²ó¤À¤±½èÍý¤ò¹Ô¤¤¤Þ¤¹¡£

¡¡for ʸ¤Ï¡¢¼Â¿ôÃͤËÃÖ¤­´¹¤¨¤Æ¹Í¤¨¤ë¤ÈÍý²ò¤¬¿¼¤Þ¤ê¤Þ¤¹¡£

¡¡º£²ó¤Î½èÍý¤Ï¡¢²¼µ­¤Î¤è¤¦¤Ê½èÍý¤Ç¤¹¤Î¤Ç

layerInfo[i] = anim.GetCurrentAnimatorStateInfo(i);

¡¡¤³¤Î i ÊÑ¿ôÉôʬ¤ò¼Â¿ôÃͤˤ·¤ÆÃÖ¤­´¹¤¨¤Æ¹Í¤¨¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£

layerInfo[0] = anim.GetCurrentAnimatorStateInfo(0);

¡¡¤è¤Ã¤Æ¡¢¼ÂºÝ¤Ë¤Ï¤³¤Î¤è¤¦¤Ê¡¢layerInfo[0] ¤ÎÍ×ÁǤȤ·ÂåÆþ½èÍý¤¬¹Ô¤ï¤ì¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ê¤Þ¤¹¡£



overrideController[overrideClipName] = this.charaData.charaAnim;

¡¡overrideController ÊÑ¿ô¤Ï Animator ¥¯¥é¥¹¤¬ÍÑ°Õ¤·¤Æ¤¤¤ë Dictinary ·¿¤ÎÊÑ¿ô¤Ç¤¹¡£
Key ¤Ï string ·¿¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢Ê¸»úÎó¤ÎÃͤò»ØÄꤹ¤ë¤³¤È¤Ç Value ¤ÎÃͤò¹¹¿·¤Ç¤­¤Þ¤¹¡£

¡¡º£²ó¤Ï string ·¿¤Î overrideClipName ÊÑ¿ô¤òÄêµÁ¤·¤Æ¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢¤³¤ÎÃͤò Key ¤È¤·¤Æ»ØÄꤷ¡¢
this.charaData.charaAnim ÊÑ¿ô¤Î¾ðÊó¤ò Value ¤È¤·¤ÆÂåÆþ½èÍý¤·¤Æ¤¤¤Þ¤¹¡£

¡¡¤³¤Î½èÍý¤Ë¤è¤ê¡¢overrideController ¤ËÀßÄꤷ¤Æ¤¤¤ë¥¢¥Ë¥á¤Î¾ðÊó¤ò¡¢º£²óÍøÍѤ¹¤ë¥­¥ã¥éÀìÍѤΥ¢¥Ë¥á¤Î¾ðÊó¤Ë¹¹¿·¤·¤Þ¤¹¡£



anim.runtimeAnimatorController = overrideController;  

¡¡Àè¤Û¤É overrideController ¤ÎÆâÍƤò¹¹¿·¤·¡¢¸½ºßÍøÍѤ·¤Æ¤¤¤ë¥­¥ã¥é¤Î¥Ç¡¼¥¿¤Î¥¢¥Ë¥á¾ðÊó¤Ë¹¹¿·¤·¤ÆÃÖ¤­´¹¤¨¤¿¤Î¤Ç¡¢
¤½¤ì¤òºÆÅÙ¡¢runtimeAnimatorController ¤ËŬÍѤ·¡¢¹¹¿·¤·¤¿¥¢¥Ë¥á¤Î¾ðÊó¤òÀßÄꤷ¤Þ¤¹¡£

¡¡overrideController ¤Ë¾ðÊó¤òÀßÄꤷ¤¿¤À¤±¤Ç¤ÏÈ¿±Ç¤µ¤ì¤Ê¤¤¤¿¤á¡¢ÀßÄê¸å¡¢¤³¤Î¹¹¿·¤Î½èÍý¤ò¹Ô¤¦¤³¤È¤ÇÈ¿±Ç¡¦Å¬ÍѤµ¤ì¤Þ¤¹¡£



anim.Update(0.0f);  

¡¡¤³¤Î Update ¥á¥½¥Ã¥É¤Ï Animator ¥¯¥é¥¹¤ËÍÑ°Õ¤µ¤ì¤Æ¤¤¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£(Ä̾ï¤Î Update ¥á¥½¥Ã¥É¤Ç¤Ï¤Ê¤¤¡¢¤È¤¤¤¦¤³¤È¤Ç¤¹¤Í)
¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¹¹¿·ÀßÄê¤òÈ¿±Ç¤µ¤»¤ë½èÍý¤Ç¤¹¡£¤³¤Î½èÍý¤òÆþ¤ì¤Æ¤ª¤¯¤ÈÀßÄꤷ¤¿¿·¤·¤¤¥¢¥Ë¥á¤¬Â¨ºÂ¤ËŬÍѤµ¤ì¤Þ¤¹¡£


Unity ¥¹¥¯¥ê¥×¥È¡¦¥ê¥Õ¥¡¥ì¥ó¥¹
Animator



for (int i = 0; i < anim.layerCount; i++)
{
    anim.Play(layerInfo[i].fullPathHash, i, layerInfo[i].normalizedTime);
}

¡¡¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¾õÂÖ¾ðÊó¤ò»ÈÍѤ·¤Æ¡¢¥¢¥Ë¥á¡¼¥¿¡¼¤Î³Æ¥ì¥¤¥ä¡¼¤ÇºÆÀ¸Ãæ¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òÉü¸µ¤·¤Þ¤¹¡£

¡¡layerInfo[i].fullPathHash ÊÑ¿ô¤Ï¡¢ºÆÀ¸Ãæ¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¥Õ¥ë¥Ñ¥¹¤Î¥Ï¥Ã¥·¥åÃÍ(int ·¿)¤ò¼èÆÀ¤·¡¢
i ÊÑ¿ô¤Ï¥ì¥¤¥ä¡¼¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹(0 ¤Î¾ì¹ç¡¢BaseLayer)¡¢layerInfo[i].normalizedTime ÊÑ¿ô¤Ï¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎºÆÀ¸»þ´Ö¤òÀµµ¬²½¤·¤¿ÃÍ(0-1)¤òɽ¤·¤Þ¤¹¡£
¤³¤ì¤é¤Î¾ðÊó¤ò»ÈÍѤ·¤Æ¡¢³Æ¥ì¥¤¥ä¡¼¤ÇºÆÀ¸Ãæ¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò»ØÄꤷ¤¿»þ´Ö°ÌÃÖ¤«¤éºÆ³«¤·¤Þ¤¹¡£

¡¡¥Õ¥ë¥Ñ¥¹¤È¤Ï¥¹¥Æ¡¼¥È¤Î³¬Áع½Â¤¤Î¤³¤È¤Ç¤¹¡£BaseLayer ¤ÎÃæ¤Ë¥¹¥Æ¡¼¥È¤¬Â¸ºß¤·¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
´ðËÜŪ¤Ë¤Ï¡¢BaseLayer.Idle ¤È¤¤¤Ã¤¿·Á¤Ç¿Æ»Ò´Ø·¸¤¬¹½ÃÛ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤³¤Î¾ðÊó¤ò¥Ï¥Ã¥·¥åÃͤǤ¢¤ë int ·¿¤ËÊÑ´¹¤·¤¿¤â¤Î¤¬ fullPathHash ÊÑ¿ô¤Ç¤¹¡£
¤³¤³¤Ç»ØÄꤷ¤Æ¤¤¤ë¤Î¤Ï¡¢¸½ºß¡¢¥²¡¼¥à²èÌ̤ǺÆÀ¸¤·¤Æ¤¤¤ë¥¢¥Ë¥á¤Î¥¹¥Æ¡¼¥È¤Î¾ðÊó¤òÀ©¸æ¤¹¤ë¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
º£²ó¤Î¾ì¹ç¤Ç¤¢¤ì¤Ð¡¢°ÜÆ°ÍѤΥ¹¥Æ¡¼¥È¤ËÂФ·¤ÆÌ¿Îᤷ¤Æ¤¤¤Þ¤¹¡£

¡¡normalizedTime ÊÑ¿ô¤Ï¥¢¥Ë¥á¤ÎºÆÀ¸»þ´Ö¤ò¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎŤµ¤Ç³ä¤ê¡¢0¤«¤é1¤ÎÈϰϤËÀµµ¬²½¤·¤Þ¤¹¡£
Î㤨¤Ð¡¢ºÆÀ¸»þ´Ö¤Î¥È¡¼¥¿¥ë¤¬2ÉäΥ¢¥Ë¥á¤Ç¤¢¤ì¤Ð¡¢¤½¤ì¤¬ºÆÀ¸¤µ¤ì¤Æ¸½ºß1ÉäǤ¢¤ë¤È¤­¡¢Àµµ¬²½¤ò¹Ô¤¦¤È 0.5 ¤È¤¤¤¦Ãͤˤʤê¤Þ¤¹¡£

¡¡¤·¤¿¤¬¤Ã¤Æ¡¢¤³¤ÎÉôʬ¤òÈ´¤¯¤È¡¢¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎºÆÀ¸°ÌÃÖ¤ä¾õÂÖ¤¬ÊÝ»ý¤µ¤ì¤º¡¢¿·¤·¤¤¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬ºÇ½é¤«¤éºÆÀ¸¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£



¡¡¤³¤³¤Þ¤ÇÀâÌÀ¤ÎÄ̤ꡢ²¼µ­¤Î½èÍý¤Ï¤Ê¤¯¤Æ¤â¡¢¥¢¥Ë¥á¤ÎÊѹ¹¼ê³¤­¼«ÂΤϽªÎ»¤·¤Æ¤¤¤Þ¤¹¡£

anim.Update(0.0f);

for (int i = 0; i < anim.layerCount; i++)
{
    anim.Play(layerInfo[i].fullPathHash, i, layerInfo[i].normalizedTime);
}

¡¡¤¿¤À¤·¡¢¹¹¿·¤·¤¿¥¢¥Ë¥á¤¬¤¹¤°¤ËŬÍѤµ¤ì¤Ê¤«¤Ã¤¿¤ê¡¢ÅÓÃæ¤À¤Ã¤¿¥¢¥Ë¥á¤¬ºÇ½é¤«¤éºÆÀ¸¤µ¤ì¤Æ¤·¤Þ¤¦¤È°ãÏ´¶¤ò´¶¤¸¤Æ¤·¤Þ¤¦¤¿¤á¡¢
¤³¤¦¤¤¤Ã¤¿¤Á¤ç¤Ã¤È¤·¤¿Éôʬ¤¬¼Â¤Ï¥²¡¼¥à¤Î²èÌ̤ǤϤ¹¤´¤¯ÉÔ¼«Á³¤Ë±Ç¤ê¤Þ¤¹¡£

¡¡¤½¤³¤Ç¾åµ­¤Î½èÍý¤ò¹Ô¤¤¡¢¥²¡¼¥à²èÌ̤¬¼«Á³¤Ë±Ç¤ë¤è¤¦¤Ë½èÍý¤ò»Ü¤·¤Æ¤¤¤Þ¤¹¡£
µ¤ÇÛ¤ê¤Î¤è¤¦¤Ê¤â¤Î¤Ç¤¹¤¬¡¢¤³¤¦¤·¤¿£±¤Ä£±¤Ä¤Î¾®¤µ¤Ê½èÍý¤¬½ÅÍפǤ¹¡£


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


¡¡¥­¥ã¥é¤òÇÛÃÖ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£
CharaData ¤ËÅÐÏ¿¤·¤¿ AnimationClip ¤Ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬º¹¤·Âؤï¤ì¤ÐÀ©¸æÀ®¸ù¤Ç¤¹¡£

¡¡¤â¤·¤â¾å¼ê¤¯¤¤¤«¤Ê¤¤¾ì¹ç¤Ë¤Ï¡¢AnimationController ¤Î¾ðÊó¤ò Animator ¥Ó¥å¡¼¤Ç³Îǧ¤·¡¢
Motion ¤ÎÉôʬ¤Î AnimationClip ¤Î̾Á°¤È¡¢¥¹¥¯¥ê¥×¥ÈÆâ¤ÎÅÐÏ¿¤È¤¬Áê°ã¤·¤Æ¤¤¤Ê¤¤¤«¤ò¥Á¥§¥Ã¥¯¤·¤Æ¤¯¤À¤µ¤¤¡£


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


¡¡¤³¤ì¤Ç¥¹¥¯¥ê¥×¥¿¥Ö¥ë¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò³èÍѤ·¤Æ¡¢ÇÛÃÖ¤¹¤ë¥­¥ã¥é¤Î¾ðÊó¤òÀßÄꤹ¤ë¤³¤È¤Ç¡¢
£±¤Ä¤Î¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤ò°Û¤Ê¤ë¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Ë¤Ê¤ë¤è¤¦¤Ë¾ðÊó¤òÀßÄꤹ¤ë½èÍý¤¬´°À®¤Ç¤¹¡£



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

¡¡¼¡¤Ï¡¡¼ê½ç£²£´¡¡¡Ý¥²¡¼¥à¤Î¿Ê¹Ô´ÉÍý¤ÎÀ©¸æµ¡Ç½¤Î¼ÂÁõ­¡¡Ý¡¡¤Ç¤¹¡£

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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