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

AnyState¤Ë¤Ä¤¤¤Æ


¡¡AnyState¤äAnimator¼«ÂΤÎÀâÌÀ¤Ë¤Ä¤¤¤Æ¤Ï³ä°¦¤·¤Þ¤¹¡£¤³¤Á¤é¤Îµ­»ö¤ò»²¹Í¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£Â¾¤Ë¤â¿§¡¹¤ÊÌò¤ËΩ¤Äµ­»ö¤¬¤¢¤ê¤Þ¤¹¡£
YTTMWORKÍÍ
Animator
https://yttm-work.jp/unity/unity_0018.html
¡¡
¡¡AnyState¤Ï¾ò·ï¤òËþ¤¿¤»¤Ð¼«Æ°Åª¤ËAnimationState¤òÁ«°Ü¤·¤Æ¤¯¤ì¤ëµ¡Ç½¤Ç¤¹¡£
¤½¤¦¤¹¤ë¤³¤È¤Ç¡¢³ÆStateƱ»Î¤òTransition¤Ç¤Ä¤Ê¤°¤³¤È¤Ê¤¯¡¢AnimationState¤ÎÁ«°Ü¤¬²Äǽ¤Ë¤Ê¤ê¤Þ¤¹¡£
¾å¼ê¤Ë³èÍѤ¹¤ë¤³¤È¤Ç¡¢¸«¤¿Ìܤˤâ¤ï¤«¤ê¤ä¤¹¤¯¤Ê¤ê¤Þ¤¹¡£



AnimatorStateÍѤÎenum¤òºîÀ®¤¹¤ë


¡¡¤Þ¤º¤ÏÁ«°Ü¤¹¤ëºÝ¤Î½èÍý¤Ë»ÈÍѤ¹¤ëʸ»úÎó¤òEnum¤Ë¤·¤Æ¤ª¤­¤Þ¤·¤ç¤¦¡£
¤³¤ì¤Çʸ»úÎó¤òľÀܵ­½Ò¤»¤º¤Ë¡¢Á«°Ü²Äǽ¤ÊState¤À¤±¤òÁª¤Ö¤³¤È¤¬½ÐÍè¤Þ¤¹¡£

¡¡¡¡private enum AnimatorState {    // ÍÑÅӤ˱þ¤¸¤Æpublic¤ËÊѹ¹¤·¤Æ¤¯¤À¤µ¤¤
        Attack,
	Jump,
	Speed,
	AttackSpeed,
    }

Animator¤ÎParameters¤òÅÐÏ¿¤¹¤ë


¡¡Àè¤Û¤É¤Î²èÁü¤Ë¤â¤¢¤ê¤Þ¤·¤¿¤è¤¦¤Ë¡¢º£²ó¤Ï°Ê²¼¤ÎParameter¤òÍÑ°Õ¤·¤Þ¤·¤¿¡£Layers¤ÏBaseLayer¤Î¤ß¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£

¡¦Speed¡¡¡¡¡¡¡¡¡¡¡¡Float·¿¡£°ÜÆ°ÍѤÎStateÁ«°ÜÍÑ
¡¦AttackSpped¡¡¡¡¡¡Float·¿¡£¹¶·â»þ¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó®ÅÙ¤ÎÀßÄêÍÑ

AnimationClip¤ÎÀßÄê

¡¡º£²óÍøÍѤ·¤¿AnimationClip¤Î°ìÍ÷¤Ç¤¹¡£³Æ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÏŬµ¹¤Ê¤â¤Î¤òÍøÍѤ·¤Þ¤·¤ç¤¦¡£
Idle¡ÊÂÔµ¡ÍÑ¡£Speed¤ÎÃͤÇÁ«°Ü¤¹¤ë¡£Unitychan¤ËÆþ¤Ã¤Æ¤¤¤ëAnimationClip¡Ë


Locomotion¡Ê°ÜÆ°ÍÑ¡£Speed¤ÎÃͤÇÁ«°Ü¤¹¤ë¡£Unitychan¤ËÆþ¤Ã¤Æ¤¤¤ëAnimationClip¡Ë


Attack¡Ê¹¶·âÍÑ¡£AnyState¤«¤éÁ«°Ü¤¹¤ë¡Ë
Speed¤Î¹àÌܤˤ¢¤ëMultiplier¥×¥í¥Ñ¥Æ¥£¤ÎParameter¤Ë¥Á¥§¥Ã¥¯¤ò¤¤¤ì¤ë¤È¡¢Speed¤ÎÃͤò¥¹¥¯¥ê¥×¥È¤«¤éÊÑ¿ô¤Ë¤è¤Ã¤ÆÊѲ½¤µ¤»¤ë¤³¤È¤¬¤Ç¤­¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¤³¤ÎParameter¤ËÁªÂò¤Ç¤­¤ë¤â¤Î¤ÏÅÐÏ¿¤µ¤ì¤Æ¤¤¤ëParameter¤Î¤ß¤Ë¤Ê¤ê¤Þ¤¹¡£º£²ó¤Ï¤³¤ÎSpeed¤ÎÃͤÎÊѹ¹ÍѤËParameter¤ËAttackSpeed¤òÍÑ°Õ¤·¤Þ¤·¤¿¤Î¤Ç¡¢
¤½¤Á¤é¤ò»ØÄꤷ¤Þ¤¹¡£¡ÊFloat·¿¤ÎParameter¤Î¤ßÁªÂò¤Ç¤­¤Þ¤¹¡Ë


Jump¡Ê¥¸¥ã¥ó¥×ÍÑ¡£AnyState¤«¤éÁ«°Ü¤¹¤ë¡Ë


Transiton¤ÎÀßÄê


¡¡º£²óÀßÄê¤ò¤·¤¿Transiton¤Î²èÁü¤Ç¤¹¡£
¡¡AnyState¤«¤éAttack¤ÈJump¤Ë¤ÏTransiton¤òÉÔÍפǤ¹¡£¤½¤ì¤ÏAnimator.Play()¥á¥½¥Ã¥É¤ò»È¤¦¤¿¤á¤Ç¤¹¡£

¡¡Animator.Play¥á¥½¥Ã¥É¤Ï¸½ºß¤ÎState¤¬¤É¤³¤Ë¤¢¤Ã¤Æ¤â(¾¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÅÓÃæ¤Ç¤â)¡¢¥¹¥¯¥ê¥×¥È¤«¤é°ú¿ô¤Ç»ØÄꤷ¤¿State¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤òºÆÀ¸¤Ç¤­¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£

Animator.Play¥á¥½¥Ã¥É¤Ë¤Ä¤¤¤Æ¤Ï¸ø¼°¥ê¥Õ¥¡¥ì¥ó¥¹¤ò»²¾È¤·¤Æ¤¯¤À¤µ¤¤¡£
Unity¸ø¼°
Animator.Play
https://docs.unity3d.com/ja/current/ScriptReferenc...

¤³¤Î¥á¥½¥Ã¥É¤Ë¤Ï¥ª¡¼¥Ð¡¼¥í¡¼¥É¤¬£²¤Ä¤¢¤ê¤Þ¤¹¤¬¡¢º£²ó¤ÏºÇ½é¤Î½èÍý¤òÍøÍѤ·¤Æ¤¤¤Þ¤¹¡£
public void Play (string stateName, int layer= -1, float normalizedTime= float.NegativeInfinity);

¾¤Ë¤â¤ï¤«¤ê¤ä¤¹¤¤µ­»ö¤¬¤¢¤ê¤Þ¤¹¡£¤³¤Îµ­»ö¤òÆɤó¤Çĺ¤¯¤È¡¢Animator.Play¤Ë¸þ¤¤¤Æ¤¤¤ë¥¢¥Ë¥á¤È¸þ¤¤¤Æ¤¤¤Ê¤¤¥¢¥Ë¥á¤ÎÍý²ò¤¬¿¼¤Þ¤ê¤Þ¤¹¡£
Animator.Play¥á¥½¥Ã¥É¤Ï°ÜÆ°·Ï¤Ï¸þ¤¤¤Æ¤¤¤Ê¤¯¤Æ¡¢¥È¥ê¥¬¡¼·Ï¤Î½èÍý¤Ë¤Ï¸þ¤¤¤Æ¤¤¤ë¤³¤È¤¬Ê¬¤«¤ê¤Þ¤¹¡£
UNITY¤ÇËâʪ»È¤¤¡ê¥²¡¼¥à¤òºî¤ë
Unity¤Ç3D¤ÎARPG¥Õ¥ê¡¼¥²¡¼¥à¤òÀ©ºîÃ桪¡ÚUnityC#¹ÖºÂ¡Û¥æ¥Ë¥Æ¥£¤Á¤ã¤ó¤Ç¤â¤Ã¤ÈAnimator Controller¤ò¾å¼ê¤¯»È¤¤¤¿¤¤
https://unity-shoshinsha.biz/archives/471

Idle => Locomotion


Locomotion => Idel


Attack => Exit


Jump => Exit


Animator´ØÏ¢¤Î½èÍý¤ò¥¹¥¯¥ê¥×¥È¤Ëµ­½Ò¤¹¤ë


¡¡°ÜÆ°¤È¹¶·â¤È¥¸¥ã¥ó¥×¤Î¥¢¥Ë¥áºÆÀ¸½èÍý¤Î¤Ï¤¤¤Ã¤¿PlayerController¤Î¥µ¥ó¥×¥ë¥¹¥¯¥ê¥×¥È¤Ç¤¹¡£

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


¡¡¼Â¹Ô¤·¤Æ¡¢¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÁ«°Ü¤ò³Îǧ¤·¤Þ¤¹¡£
°ÜÆ°Ãæ¤Ë¥¸¥ã¥ó¥×¤ä¹¶·â¤¬¹Ô¤ï¤ì¤¿¾ì¹ç¡¢°ÜÆ°¤Î¥¢¥Ë¥á¤òÃæÃǤ·¤Æ¡¢¥¸¥ã¥ó¥×¤Ê¤É¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤¬ºÆÀ¸¤µ¤ì¤Æ¤¤¤Þ¤¹¡£

https://gyazo.com/3182c7d8b87bf489b71823cd84cf0d61

Ʊ¤¸¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò²¿ÅÙ¤â¥ë¡¼¥×¤·¤Æ¤·¤Þ¤¦¾ì¹ç(Can Transition To Self¤ÎÀßÄê¤ò³Îǧ¤¹¤ë)


¡¡Animator Æâ¤Î AnyState ¤«¤éÁ«°Ü¤¹¤ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Î¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Ë¡¢CanTransitionToSelf ¤È¤¤¤¦¹àÌܤ¬¤¢¤ê¤Þ¤¹¡£
¤³¤Á¤é¤Î¥Á¥§¥Ã¥¯¤¬Æþ¤Ã¤Æ¤¤¤ë¤È¡¢¼«Ê¬¼«¿È¤ÎState¤ËÂФ·¤ÆÁ«°Ü¤¹¤ë¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Ë¤Ä¤¤¤Æ¤Ï̵»ë¤µ¤ì¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡Ê°ìÅÙºÆÀ¸¤µ¤ì¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ËÂФ·¤Æ¡¢·«¤êÊÖ¤·¤Î½èÍý¤ò¹Ô¤ï¤Ê¤¯¤Ê¤ê¤Þ¤¹¡Ë

¡¡Æ±¤¸¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ò²¿ÅÙ¤â¥ë¡¼¥×¤·¤Æ¤·¤Þ¤¦¤è¤¦¤Ê»þ¤Ë¤Ï¡¢¤³¤Î¹àÌܤò³Îǧ¤·¤Æ¥Á¥§¥Ã¥¯¤ò³°¤¹¤è¤¦¤Ë¤·¤Þ¤·¤ç¤¦¡£

¡¡¤³¤Á¤é¤Îµ­»ö¤Ë¾Ü¤·¤¤ÀâÌÀ¤¬ºÜ¤Ã¤Æ¤¤¤Þ¤¹¤Î¤Ç»²¹Í¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£

¥Æ¥é¥·¥å¡¼¥ë¥Ö¥í¥°ÍÍ
¡ÚUnity¡ÛAnimationController¤ÎAnyState¤ò»ÈÍѤ·¤Æ¤ëºÝ¡¢¸½ºß¤ÎState¤Ø²¿ÅÙ¤â°ÜÆ°¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤ë
http://tsubakit1.hateblo.jp/entry/2017/01/13/23300...

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


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

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

Menu


´ðÁÃ

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

private



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

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