ãUnity1ãã¢ãã¡ã¼ã·ã§ã³å®è£ ï¼Animationã¨Animator Controllerãã¦ããã£ã¡ãã縦ã¹ã¯ãã¼ã«7ã
Unity5.1.1f1 Personal(2015å¹´6æ)
Â
ãã®ã³ã³ãã³ãã¯ããã¦ããã£ã¡ããã©ã¤ã»ã³ã¹ãã§æä¾ããã¦ãã¾ã
Â
 ååã®ç¶ãã§ãã
ä»åã¯ãã¦ããã£ã¡ããã«èµ°ãã¨ã¸ã£ã³ãã®ã¢ãã¡ã¼ã·ã§ã³ãå ãããã¨æãã¾ãã
Â
ä»åã®ãããª2Dç»åã®ã¢ãã¡ã¼ã·ã§ã³ã詳ããã¾ã¨ããã¨ãã»ã³ã¹ããç¨æãã¾ããã®ã§ããã¡ãããåç §ä¸ããã
Â
Â
 ãç®æ¨ãèµ°ãã¨ã¸ã£ã³ãã®ã¢ãã¡ã¼ã·ã§ã³ãä»ããï¼
Â
â èµ°ãã¢ãã¡ã¼ã·ã§ã³ãä½æããï¼
ã¾ãã¯èµ°ãã¢ãã¡ã¼ã·ã§ã³ãä½æãã¾ããHierarchyãã¥ã¼ã®Playerãé¸æãã
Â
Â
ãã®ç¶æ ã§Window>Animationãã¯ãªãã¯ãã
Â
Â
ãããªè¡¨ç¤ºããã£ããCreateãã¿ã³ãæ¼ãã
Â
Â
ããä¸ã®è¡¨ç¤ºãåºãªãã£ããAnimationãã¥ã¼ã®CreateNewClipãã¯ãªãã¯ãã
Â
Â
Dash@Playerã¨ããååã§Animationãä¿åãã
Â
Â
AddProperty>SpriteRenderer>Spriteãé¸æãã
Â
Â
Projectãã¥ã¼ããã¦ããã£ã¡ãããããçµµç´ æ(Co89)>ã¦ããã£ã¡ãã_èµ°ãããã¦ããã£ã¡ãã_èµ°ã_0ã8ãã¾ã¨ãã¦ãã©ãã°ããAnimationãã¥ã¼ã¸ããããï¼(2æã®Spriteç»åãããããããã¾ãããããããã¯åé¤ãã¦ä¸ãã)
 ãã©ãã°ï¼ããããï¼
Â
表示ãããSpriteç»åã¯ã Animationã®ã¿ã¤ã ã©ã¤ã³ã§ãã0:00ã0:08ã«ç¶ºéºã«ä¸¦ã¹ã¦ä¸ããã
Â
0:00ã0:08ã«ç¶ºéºã«ä¸¦ã¹ç´ã
Â
ããã§èµ°ãã¢ãã¡ã¼ã·ã§ã³ãä»ãã¾ããããã»ã»ã»ãã®ç¶æ ã ã¨ãã®ãããã¹ãã¼ãã§ã¢ãã¡ã¼ã·ã§ã³ãã¦ãã¦æ°æã¡æªãã®ã§ãanimationã¦ã£ã³ãã¦ã®Samples(1ç§éã«ä½ã³ãã®ã¢ãã¡ã¼ã·ã§ã³ã«ããã)ã60ãã15ã«ãã¦ãã¢ãã¡ã¼ã·ã§ã³ã¹ãã¼ããããããã«ãã¾ãã
Â
60ãã15ã¸å¤æ´
Â
ããã§ã¡ããã©ããã¹ãã¼ãã«ãªãã¾ãããã²ã¼ã ãå®è¡ãã¦ã¿ã¾ãã
Â
ããè¾¼ãã©ãã»ã»ã»
Â
ã¦ããã£ã¡ãã_å¾ æ©ã®Spriteç»åã®PivotãCenterããBottomã«å¤æ´ãã¾ããããèµ°ããã¸ã£ã³ãã®Spriteç»åã®Pivotã¯ã¾ã Centerã®ã¾ã¾ãªã®ã§ããã®ãããªçµæã¨ãªã£ã¦ãã¾ãã¾ãããã®ã§ãå¤æ´ãã¾ãã
Â
ã¦ããã£ã¡ãã_èµ°ãã®Sprite Editorã®è¨å® PivotãBottomã«å¤æ´
Â
ã¤ãã§ã«ãã®ãã¨ä½¿ãã¸ã£ã³ãã¢ãã¡ã¼ã·ã§ã³ã®PivotãBottomã«å¤æ´ãã¦ããã¾ãã
Â
ã¦ããã£ã¡ãã_ã¸ã£ã³ãã®Sprite Editorè¨å® PivotãBottomã«
Â
ããã§ã¯å度ãã²ã¼ã ãå®è¡ãã¦ã¿ã¾ãããã
Â
èµ°ã£ã¦ã¾ã
Â
â¡ã¸ã£ã³ãã¢ãã¡ã¼ã·ã§ã³ãä½æãã
ç¾å¨Dash@Playerã¨ããã¢ãã¡ã¼ã·ã§ã³ã®ã¿ãåå¨ãã¦ã¾ãããããã²ã¨ã¤Jump@Playerã¨ããã¢ãã¡ã¼ã·ã§ã³ãä½æããæ¡ä»¶ã«ãã£ã¦ã¢ãã¡ã¼ã·ã§ã³ãå¤ãã¦ããã¾ãããã
Â
Hierarchyãã¥ã¼ã«ããPlayerãé¸æããWindowããAnimationãå度é¸æãã¾ãã
Â
Â
 次ã«Dash@Playerã¨æ¸ããã¦ããæ¬ãã¯ãªãã¯ããCreate New Clipã¨ããé ç®ãããã¾ãã®ã§ã¯ãªãã¯ãã¾ãã
Â
Â
Jump1@Playerã¨ããååã§ä¿åãã¾ãï¼
Â
Â
ããã¨Dash@Playerã¨åãç»é¢ãåºã¦ãã¾ãã®ã§ãAdd Property > Sprite Renderer > Spriteãé¸æããProjectæ¬ã®ã¦ããã£ã¡ãããããçµµç´ æ(Co89)>ã¦ããã£ã¡ãã_ã¸ã£ã³ãããã¦ããã£ã¡ãã_ã¸ã£ã³ã0ã¨1ãAnimationã¦ã£ã³ãã¦ã«è²¼ãä»ãã¾ãã
Â
ä»åSamplesã¯60ã®ã¾ã¾ã§å¤§ä¸å¤«ã§ãã
Â
ç»åã2æé ç½® Samplesã¯60ã®ã¾ã¾
Â
ãã®è¦é ã§ã
Â
åå:Jump2@Player Spriteç»å:ã¦ããã£ã¡ããã¸ã£ã³ã2,3ãSamples:15
Â
åå:Jump3@Player Spriteç»å:ã¦ããã£ã¡ããã¸ã£ã³ã4,5ãSamples:60
Â
åå:Jump4@Player Spriteç»å:ã¦ããã£ã¡ããã¸ã£ã³ã6,7ãSamples:15
Â
åå:Jump5@Player Spriteç»å:ã¦ããã£ã¡ããã¸ã£ã³ã8,0ãSamples:60
Â
ã¨ä½æãã¦ä¸ããã
Â
ããã§ã¸ã£ã³ãã¢ãã¡ã¼ã·ã§ã³ã¯å®æãã¾ããï¼
ãã¨ã¯æ¡ä»¶ãæå®ãã¦ãèµ°ãã¢ãã¡ã¼ã·ã§ã³ããä»ä½æããã¸ã£ã³ãã¢ãã¡ã¼ã·ã§ã³ã«åãæ¿ããã°OKã§ãã
Â
ç¶ãã¦Hierarchyã®Playerãé¸æããç¶æ ã§ãWindow>Animatorã¦ã£ã³ãã¦ãéãã¦ä¸ããã
Â
Â
å ã»ã©ä½æããAnimationãé ç½®ããã¦ãã¾ãã
Â
Â
â¢Animator Controllerã§ã¢ãã¡ã¼ã·ã§ã³å士ãç¹ããï¼
ããã§ã¯ã¢ãã¡ã¼ã·ã§ã³å士ãç¹ãã¦ããã¾ãã
Â
ã¾ãã¯é ç½®ã軽ãæ´çãã¾ãããï¼
Â
 ãããªæãã®é ç½®
Â
次ã«ã¢ãã¡ã¼ã·ã§ã³ãå³ã¯ãªãã¯ãã¦ãMakeTransitionãé¸æãã¾ãã
Â
æåã¯AnyStateããJump1@Playerã¸ç¢å°ãå¼ãã¾ãã
Â
Â
åãè¦é ã§ã以ä¸ã®ããã«Transitionã§ç¹ãã§ãã ããã
Â
Â
ãããããã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ããã¹ã¯ãªãããè¨è¿°ãã¾ãããã®åã«ã»ã»ã»ãã®æ¡ä»¶ç¨ã®å¤æ°ãä½ã£ã¦ããã¾ãã
Â
Animatiorç»é¢ã®å·¦å´ã«ããParametersãéãã¨ãã©ã¡ã¼ã¿è¨å®ç»é¢ãåºã¦ããã®ã§ãï¼ãã¿ã³ãæ¼ãBoolãé¸æããã¨ããã©ã¡ã¼ã¿ã¼ãä½æã§ãã¾ãã
Â
Â
ä»åãã©ã¡ã¼ã¿ã¼ã¯isGrounded(Bool)ãvelY(float)ãJump(Trigger)ã®ï¼ã¤ãä½ãã¾ãã
Â
Â
ç¶ãã¦å ã»ã©ä½æãããã©ã¡ã¼ã¿ã¼ã使ã£ã¦ãã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ããæ¡ä»¶ãè¨å®ãã¾ãï¼æåã®AnyStateâJump1@Playerã®åæ¿æ¡ä»¶ã¯ãJumpããªã¬ã¼ãå®è¡ããããã»ã»ã»ã¨ããæ¡ä»¶ã«è¨å®ãã¾ãã
Â
赤丸å°ã®ã¨ãããã¯ãªãã¯ããã¨ãInspectorã«ã¢ãã¡ã¼ã·ã§ã³åæ¿å 容ãåºã¦ãã¾ãã¦ãã¡ãã£ã¨ä¸ã®ã»ãã«Conditionsã¨ããæ¬ãããã¾ãã®ã§ãConditionsã®ãã©ã¹ãã¿ã³ãæ¼ãã¦Jumpãé¸æãã¦ä¸ãããã¾ããHasExitTimeã®ãã§ãã¯ã¯å¤ãã¦TransitionDurationã0ã«ãã¦ããã¦ä¸ããã
Â
Â
åãããã«è¨å®ãã¦ããã¾ãã
Â
Jump1@PlayerâJump2@Player
Â
Â
Jump2@PlayerâJump3@Player
Â
Jump3@PlayerâJump4@Player
Â
Jump4@PlayerâJump5@Player
Â
Jump5@PlayerâExit
Â
ãç²ãæ§ã§ãã
Â
ããã§ã¯æ¬¡ã«ãã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ããå¦çãä½æãã¦ããã¾ãããã
Â
â£ãã©ã¡ã¼ã¿ãåãæ¿ãã¢ãã¡ã¼ã·ã§ã³ãé·ç§»ããã
ããã§ã¢ãã¡ã¼ã·ã§ã³ãæããã¢ãã¡ã¼ã·ã§ã³ãç¹ããã¢ãã¡ã¼ã·ã§ã³ãåãæ¿ããå¤å®ç¨ã®ãã©ã¡ã¼ã¿ã¼ãã§ãã¾ããã
Â
ãã¨ã¯ã¹ã¯ãªãããããã©ã¡ã¼ã¿ã¼ãåãæ¿ããã ãã§ããPlayerScriptã«å çãã¦ããã¾ãï¼
Â
Â
Updateã¡ã½ããããAnimã¡ã½ãããå¼ã³åºãã¾ãã
Â
Animã¡ã½ããã§ã¯velocityã使ãY軸æ¹åã®ç§»åé度ãåå¾ããSetFloatã«ãã£ã¦ãã®å¤ãã¢ãã¡ã¼ã¿ã¼ã§ä½æããå¤æ°ã«åæ ãã¦ãã¾ããä¸æãã¦ããæã¯ãã©ã¹ãä¸éãã¦ããæã¯ãã¤ãã¹ã®å¤ãå ¥ãã¾ãã
Â
ã¾ããæ¢ã«ããisGroundedå¤æ°ããSetBoolã«ãã£ã¦ã¢ãã¡ã¼ã¿ã¼ã«ä½æããå¤æ°ã«åæ ãã¦ãã¾ãã
Â
æå¾ã«Jumpã¡ã½ããã«ã¦ãSetTriggerã«ãã£ã¦jumpããªã¬ã¼ãtrueã«ãã¦ãã¾ããããªã¬ã¼ã¯Boolåã¨ä¼¼ã¦ãã¾ããã1ãã¬ã¼ã ã ãtrueãå®è¡ãããå³åº§ã«èªåçã«falseã«å¤æ´ããã¾ããfalseã«æ»ãå¦çãæ¸ããªãã¦ããã®ã§ãé常ã«æ¥½ã§ãã
Â
ãçµæã
Â
å®å ¨ã«ã¸ã£ã³ããã¦ããã¾ãã
Â
ä»åã¯ããã¾ã§ããããã¨ããããã¾ããã
Â