ãUnityéçºãAnimator Controllerã®é·ç§»è¨å®(Durationç)ãã²ããã¨ãã»ã³ã¹ã
Unity5.1.1f1 Personal(2015å¹´6æ)
ã²ããã¨ãã»ã³ã¹ã®æéã§ãã
ä»åã¯Animator Controllerã®è¨äºã®ç¶ãã§ããé·ç§»æã®ç´°ããªè¨å®ãä¸å¿ã«è¦ã¦ããã¾ãã
Animator Controllerã®é·ç§»è¨å®(Durationç)
ååè¨äºã§IdleããWalkã¸é·ç§»ããã¢ãã¡ã¼ã·ã§ã³ãä½æãããã¨ãã§ãã¾ããããä¸ã®èµ¤æ é¨åã®è§£èª¬ã丸ã
é£ã°ãã¦ãã¾ãã¾ããã®ã§ãä»å解説ãã¦ããããã¨æãã¾ãã
Settingså¨è¾ºã®è§£èª¬ããã¾ã
ã¾ãã¯Has Exit Timeã§ãã
Has Exit Timeã®ãã§ãã¯ãå¤ãã¦ããæã¯Conditionsã«ã¦ã¢ãã¡ã¼ã·ã§ã³é·ç§»æ¡ä»¶ã決ãããã§ãã¯ãä»ãã¦ããæã¯ã¢ãã¡ã¼ã·ã§ã³åçåæ°ã決ãããããçµäºãããã¢ãã¡ã¼ã·ã§ã³é·ç§»ãã¾ãã
ç¶ãã¦Exit Timeã§ãã
Has Exit Timeã«ãã§ãã¯ãä»ãã¦ããå ´åãããã§ã¢ãã¡ã¼ã·ã§ã³ãå®è¡ããåæ°ã決ãã¾ãã
3ã«è¨å®ããã¨Stateã3åå®è¡ãããã¢ãã¡ã¼ã·ã§ã³é·ç§»ã0.5ã«è¨å®ããã¨Stateãååå®è¡ãã¦ã¢ãã¡ã¼ã·ã§ã³é·ç§»ãã¨ãã£ãå ·åã§ãã
ç¶ãã¦Fixed Durationã§ãã
Durationã¯åç¶æéã表ããUnityã§ã¯ã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ããã®ã«è¦ããæéãæå³ãã¾ãã
Durationæéå
ã§å¾ã
ã«é·ç§»å¾ã¢ãã¡ã¼ã·ã§ã³ã®åº¦åããå¼·ããã¦ãããã¨ã§ãã¹ã ã¼ãºãªã¢ãã¡ã¼ã·ã§ã³ãå®ç¾ãã¾ãã
ãã®Durationæéããé·ç§»åã¢ãã¡ã¼ã·ã§ã³ã®é·ããå ã«%ã§ç®åºããããç§ãå ã«ç®åºããã決ããã®ãFixed Durationã§ãã
Fixed Durationã«ãã§ãã¯ãå ¥ã£ã¦ããªãå ´åãé·ç§»åStateã®ã¢ãã¡ã¼ã·ã§ã³1ååã®é·ããå ã«Durationã決å®ãã¾ããåä½ã¯ï¼ ã§ãã
Transition Durationã1ã«ããå ´åãé·ç§»åStateã®1ååé·ããããã¦å¾ã ã«é·ç§»å¾ã¢ãã¡ã¼ã·ã§ã³ã¸ç§»è¡ãã¾ãã
Idle1ååã®é·ããããã¦å¾ã
ã«Walkã¸ç§»è¡
Transition Durationã0.5ã«ããå ´åãé·ç§»åã®Stateã®1åä½åã®é·ãã®ååã®æéãããã¦é·ç§»å¾ã¢ãã¡ã¼ã·ã§ã³ã¸ç§»è¡ãã¾ãã
Idleã®ååã®é·ãã§Walkã«ç§»è¡
Transition Durationã0ã«ããå ´åãã¢ãã¡ã¼ã·ã§ã³é·ç§»ã®ç¬éã«ããããªã¨ã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ãã¾ãã2Dã¢ãã¡ã¼ã·ã§ã³ã®å ´åã¯å¾ã ã«ç§»è¡ãã§ããªãã®ã§ãTransition Durationã0ã«ãã¾ãã
ã¢ãã¡ã¼ã·ã§ã³é·ç§»ã®ã¿ã¤ãã³ã°ã§å³åº§ã«ç§»è¡
FixedDurationã«ãã§ãã¯ãå ¥ã£ã¦ããå ´åãé·ç§»åStateã®é·ãã¨ã¯ç¬ç«ãã¦Durationã®é·ãã決å®ãããããªãã¡ç§ã使ã£ã¦Durationæéã決ãã¦ããã¾ãã
Transition Durationã1ã«ããã°1ç§ããã¦å¾ã ã«é·ç§»å¾ã¢ãã¡ã¼ã·ã§ã³ã¸ç§»è¡ãã¾ãã
1ç§ã§ã¢ãã¡ã¼ã·ã§ã³é·ç§»
Transition Durationã0.5ã«ããã°0.5ç§ããã¦é·ç§»å¾ã¢ãã¡ã¼ã·ã§ã³ã¸ç§»è¡ãã¾ãã
0.5ç§ã§ã¢ãã¡ã¼ã·ã§ã³é·ç§»
Transition Durationã0ã«ããã°ãã¢ãã¡ã¼ã·ã§ã³é·ç§»ã®ç¬éã«ããããªã¨ã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ãã¾ãã
ããããªã¨ã¢ãã¡ã¼ã·ã§ã³é·ç§»
ç¶ãã¦Transition Offsetã§ãã
Offsetã¯å·®åã®åãåããã表ããUnityã ã¨ã¢ãã¡ã¼ã·ã§ã³ã®éå§ä½ç½®ããºã©ãæãã®æå³ã§ä½¿ããã¦ãã¾ãã
ä¾ãã°Walkã¢ãã¡ã¼ã·ã§ã³ãå·¦âå³âå·¦âå³ã¨ããé çªã§è¶³ãåããã¦ããå ´åãTransition Offsetã0.5ã«è¨å®ããã¨ãå³âå·¦âå³âå·¦ã¨ããé çªã§è¶³ãåããããã«ãªãã¾ãã
Transition Offset=0 Walkã¯å
é ããåçããã
Transition Offset=0.5 Walkã¯çãä¸ããåçããã
ç¶ãã¦Interruption Sourceã§ãã
ããã§ã¯ã¢ãã¡ã¼ã·ã§ã³ã®ä¸æãè¨å®ã§ãã¾ãã
Noneã¯ãä¸æããã¾ããã
Current Stateã¯ãç¾å¨ã®ã¢ãã¡ã¼ã·ã§ã³åçæã«ä¸æããã¾ãã
Next State: é·ç§»å ã¢ãã¡ã¼ã·ã§ã³åçæã«ä¸æããã¾ãã
Current State Then Next Stateã¨Next State Then Current Stateã¯ãç¾å¨ãããã¯é·ç§»å ã¢ãã¡ã¼ã·ã§ã³åçæã«ä¸æããã¾ãã
Ordered Interruptionã¯ããã©ã³ã¸ã·ã§ã³ã®é çªã¨ã¯ç¬ç«ãã¦ä¸æãããã¨ãã§ããããã§ãããããæå³ãåãã£ã¦ãã¾ããã
Interruptioné¢ä¿ã«ã¤ãã¦ã¯ãã®Idleã¨Walkãè¡ãæ¥ããã¢ãã¡ã¼ã·ã§ã³ã§ãã¾ããã£ãã®ã¯ãCurrent Stateãé¸æããå°ä¸ã¤ORdered Interruptionã®ãã§ãã¯ãå¤ããæã ãã§ãããããå°ã調æ»ãããã¨æãã¾ãã
ç¶ãã¦Preview source stateã§ãããã¡ãã¯ããã¬ãã¥ã¼ç»é¢ã§ã©ã®Stateã表示ãããã決ãããã¾ãã
ã²ã¼ã åçæã«ã®ã¿è¨å®ã§ãã¾ãã
Idleãé¸æ ä¸ã®ãã¬ãã¥ã¼ç»é¢ã«Idleç¶æ
ã®ã¦ããã£ã¡ããã表示
æå¾ã«Can Transition To Selfã§ãããã¡ãã¯Triggerã使ã£ãã»ããå¹æãåãããããã®ã§ãJumpã¢ãã¡ã¼ã·ã§ã³ã追å ãã¾ãã
Any StateâJumpâExitãä½æ
Jumpããªã¬ã¼ä½æ
JumpStateã®è¨å® JUMP00ãæå®
Any StateâJumpã®Transitionè¨å®
JumpâExitã®Transitionè¨å®
ã¹ãã¼ã¹ãã¼ãæ¼ããæã«ã¸ã£ã³ãããããã«ãUnityChanScriptãå çãã¦ããã¾ãã
using UnityEngine; using System.Collections; public class UnityChanScript : MonoBehaviour { private Animator anim; void Start () { anim = GetComponent<Animator>(); } void Update () { if (Input.GetKey ("up")) { anim.SetBool ("Walk", true); } else { anim.SetBool ("Walk", false); } //********** éå§ **********// if (Input.GetKeyDown ("space")) { anim.SetTrigger("Jump"); } //********** çµäº **********// } }
UnityChanScript.cs
ã¸ã£ã³ãï¼
ããã§ã¯è©±ãCan Transition To Selfã«æ»ãã¾ãããã
Can Transition To Selfã¯ãä»åã®ããã«Any StateããTriggerã使ã£ã¦ã¢ãã¡ã¼ã·ã§ã³é·ç§»ãããæãªã©ã«å½±é¿ãã¾ãã
ã¾ãã¯Can Transition To Selfããªãã§ããå ´åã§ãã
ãã®å ´å2åé£ç¶ã§åãTriggerãå®è¡ããã¨ã1åç®ã®ã¢ãã¡ã¼ã·ã§ã³ãçµäºããã¾ã§ã2åç®ã®Triggerã¯trueã®ã¾ã¾å¾
æ©ç¶æ
ã¨ãªãã¾ãã
ã¤ã¾ã1åç®ã®ã¢ãã¡ã¼ã·ã§ã³ãçµäºããæã«ã¯ããã¦2åç®ã®Triggerãtrueããfalseã¨ãªãã2åç®ã®ã¢ãã¡ã¼ã·ã§ã³ãå®è¡ããã¾ãã
ç¶ãã¦Can Transition To Selfããªã³ã®æã§ããããã¡ãã®å ´åã¯1åç®ã®é·ç§»å
ã®ã¢ãã¡ã¼ã·ã§ã³ãçµäºããåã§ã2åç®ã®Triggerãå®è¡ããã¾ãã
ã¤ã¾ã1åç®ã®ã¢ãã¡ã¼ã·ã§ã³ã¯å¼·å¶çã«ä¸æããã2åç®ã®ã¢ãã¡ã¼ã·ã§ã³ãå®è¡ããã¾ãã
ã²ã¨éãã¢ãã¡ã¼ã·ã§ã³é·ç§»æã®è¨å®ã«ã¤ãã¦è§£èª¬ãã¾ããããã¾ã åãããªãã¨ãããå¤ãã®ã§è¿½è¨ãã¦ããã¨æãã¾ãã
以ä¸ãã²ããã¨ãã»ã³ã¹ã§ããã
ãããã¨ããããã¾ããã