ºÇ½ª¹¹¿·¡§ orika_ex_miyako 2022ǯ06·î13Æü(·î) 10:36:50ÍúÎò
Î㤨¤Ð¡¢¥¥ã¥é¤¬±¦Êý¸þ¤Ë°ÜÆ°¤·¤Æ¤¤¤ë¾ì¹ç¤Ë¤Ï¡¢°ÜÆ°¥¢¥Ë¥á¤â±¦¤ò¸þ¤¤¤Æ¤¤¤ë¤â¤Î¤òºÆÀ¸¤µ¤»¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡ã¼ÂÁõÆ°²è¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡°Ê²¼¤ÎÆâÍƤǽçÈ֤˼ÂÁõ¤ò¿Ê¤á¤Æ¤¤¤¤Þ¤¹¡£
¼ê½ç£¹¡¡¡¼¥×¥ì¥¤¥ä¡¼¥¥ã¥é¤Î°ÜÆ°¥¢¥Ë¥á¤ÎƱ´ü¡¼
£±£²¡¥PlayerController ¥¹¥¯¥ê¥×¥È¤ò½¤Àµ¤·¡¢¥×¥ì¥¤¥ä¡¼¥¥ã¥é¤Î°ÜÆ°¤ÎÊý¸þ¤È°ÜÆ°¥¢¥Ë¥á¤òƱ´ü¤µ¤»¤ë
¡¡¿·¤·¤¤³Ø½¬ÆâÍƤϡ¢°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£
¡¡¡¦Mathf.Approximately ¥á¥½¥Ã¥É ¡¡¡¦Vector2.Set ¥á¥½¥Ã¥É ¡¡¡¦Vector2.Normalize ¥á¥½¥Ã¥É ¡¡¡¦Animator.SetFloat ¥á¥½¥Ã¥É
¡¡¼ÂÁõÆ°²è¤ò³Îǧ¤·¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£¤½¤Î¤è¤¦¤ÊµóÆ°¤ò¹Ô¤¦¤¿¤á¤Ë¤Ï¤É¤¦¤¹¤ì¤Ð¤è¤¤¤«¡¢¹Í¤¨¤Æ¤ß¤Þ¤·¤ç¤¦¡£
¡¡¥Ý¥¤¥ó¥È¤Ï¼¡¤ÎÅÀ¤Ç¤¹¡£
¡¡¡¦¥¡¼ÆþÎϤò¹Ô¤¦¤È¡¢¤½¤ÎÊý¸þ¤Î¥¥ã¥é¤Î°ÜÆ°¥¢¥Ë¥á¤¬ºÆÀ¸¤µ¤ì¤ë ¡¡¡¦¥¡¼ÆþÎϤò»ß¤á¤ÆÄä»ß¤·¤¿¾ì¹ç¡¢ÀµÌ̤ËÌá¤ë¤Î¤Ç¤Ï¤Ê¤¯¡¢º£¤Þ¤Ç°ÜÆ°¤·¤Æ¤¤¤¿Êý¸þ¤Î°ÜÆ°¥¢¥Ë¥á¤¬¤½¤Î¤Þ¤ÞºÆÀ¸¤µ¤ì¤ë
¡¡º£²ó¤Ï¼ÂÁõ¤·¤Æ¤¤¤Þ¤»¤ó¤¬¡¢Ää»ßÃæ¤Î¥¢¥Ë¥á¤òÍÑ°Õ¤·¤ÆÂƧ¤ß¤ò»ß¤á¤ë¤è¤¦¤Ë¤·¤Æ¤â¤¤¤¤¤È»×¤¤¤Þ¤¹¡£
¡¡Animator ¤³¤Á¤é¤Ë¤ÆÀ½ºî¤·¤¿¥¢¥Ë¥á¤ÎÁ«°Ü½èÍý¤Ï¡¢¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤Î Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥ÈÆâ¤Ë¤¢¤ë Controller ¥×¥í¥Ñ¥Æ¥£¤ÎÉôʬ¤ÇÀ©¸æ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£
¤³¤Î¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ÏÊ£¿ô¤Î²èÁü¤ò¤Þ¤È¤á¤Æ¥Ò¥¨¥é¥ë¥¡¼¤Ë¥É¥é¥Ã¥°¥¢¥ó¥É¥É¥í¥Ã¥×¤·¤¿ºÝ¤Ë¤Ï¡¢¼«Æ°Åª¤ËÄɲ䵤ì¤Þ¤¹¡£
Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È
¡¡Controller ¥×¥í¥Ñ¥Æ¥£¤ËÅÐÏ¿¤µ¤ì¤Æ¤¤¤ë¾ðÊ󤬡¢Àè¤Û¤É Blend Tree ¤Ê¤É¤òÀßÄꤷ¤¿¾ðÊó¤Ë¤Ê¤ê¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢¤³¤Î Controller ¤òÊѹ¹¤¹¤ë¤³¤È¤Ë¤è¤Ã¤Æ¡¢°Û¤Ê¤ë¥¢¥Ë¥á¤ÎÁ«°Ü¤ò¹Ô¤¦¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡
¡¡¤Þ¤¿ Animator ¥Ó¥å¡¼¤Î Parameters ¤ËÀßÄꤷ¤¿¾ðÊó¤òÁàºî¤¹¤ë¤¿¤á¤Ë¤â¡¢¤³¤Î Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤¬É¬Íפˤʤê¤Þ¤¹¤Î¤Ç¡¢
¥¢¥Ë¥á¤ÎÀ©¸æ¤ò¹Ô¤¦¾ì¹ç¤Ë¤Ï¡¢¤³¤Î Animator ¥³¥ó¥Ý¡¼¥Í¥ó¥È¤ò¥¹¥¯¥ê¥×¥ÈÆâ¤ÇÊÑ¿ô¤Ë¼èÆÀ¤·¤Æ¡¢¤½¤ì¤òÍøÍѤ¹¤ë¤È¤¤¤¦ÊýË¡¤ÇÀ©¸æ¤ò¹Ô¤¤¤Þ¤¹¡£
¡¡°ÜÆ°¤ËºÝ¤·¤Æ¥¡¼ÆþÎÏ¤Ï InputManager ¤Îµ¡Ç½¤òÍøÍѤ·¤Æ¡¢Horizontal¡¢Vertical ¤ÎÃͤ«¤é°ÜÆ°¤¹¤ë¤¿¤á¤ÎÃͤò¼èÆÀ¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤Î¾ðÊó¤ò³èÍѤ·¤Æ¡¢¡Ö¸½ºß¥×¥ì¥¤¥ä¡¼¥¥ã¥é¤¬¸þ¤¤¤Æ¤¤¤ëÊý¸þ¡×¤Î¾ðÊó¤òÀßÄê½ÐÍè¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡¡¾å²¼º¸±¦¤ÎÊý¸þ¤¬¤¢¤ê¤Þ¤¹¤Î¤Ç¡¢Vector2 ·¿¤ÎÊÑ¿ô¤òÍÑ°Õ¤·¤Æ¡¢¿åÊ¿Êý¸þ¤È¿âľÊý¸þ¤Î¾ðÊó¤òÂåÆþ¤Ç¤¤ë¤è¤¦¤Ë¤¹¤ì¤Ð
¾å²¼º¸±¦¤ÎÊý¸þ¤ËÂбþ½ÐÍè¤ë¤è¤¦¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡¤³¤ÎÃͤòÍøÍѤ·¤Æ¡¢°ÜÆ°¥¢¥Ë¥á¤ÎÊý¸þ¤âÀ©¸æ¤¹¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡¡Blend Tree ¤ÎÉôʬ¤Ç¥¥ã¥é¤Î¥¢¥Ë¥á¤¬ÃͤÎÊѲ½¤Ë¹ç¤ï¤»¤Æ¾å²¼º¸±¦¤ÎÊý¸þ¤ËÀÚ¤êÂؤï¤Ã¤¿¤È»×¤¤¤Þ¤¹¡£
¤½¤ÎÉôʬ¤ÎÀ©¸æ¤Ë¡¢¤³¤ÎÃͤòÍøÍѤ·¡¢Î㤨¤Ð±¦Êý¸þ( Vector2 (1, 0) )¤ÎÃͤ¬¼èÆÀ½ÐÍ褿¾ì¹ç¤Ë¤Ï¡¢¤½¤ÎÃͤò Blend Tree ¤ÎÃͤÈƱ´ü¤µ¤»¤ë¤³¤È¤Ë¤è¤ê¡¢
°ÜÆ°¥¢¥Ë¥á¤ò±¦Êý¸þ¤ò¸þ¤¤¤ÆÊ⤤¤Æ¤¤¤ë¥¢¥Ë¥á¤ËÀÚ¤êÂؤ¨¤ë¤è¤¦¤Ë¤·¤Þ¤¹¡£
¡ãBlend Tree ¤È Parameter¡ä
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡Æ°²è¤ò´Ñ¤ë¤È¤ï¤«¤ê¤Þ¤¹¤¬¡¢¥¤¥ó¥¹¥Ú¥¯¥¿¡¼¤Î Parameter ¤òÁàºî¤·¤Æ¥¥ã¥é¤Î¥¢¥Ë¥á¤¬ÀÚ¤êÂؤï¤ë¤È
Blend Tree ¤ÎÃæ¤Ë¤¢¤ë Look X ¤È Look Y ¤ÎÃͤ¬°ì½ï¤ËÆ°¤¤¤Æ¤¤¤ë¤³¤È¤¬¤ï¤«¤ê¤Þ¤¹¡£
¤Ä¤Þ¤ê¡¢¥¥ã¥é¤Î¸þ¤¤¤Æ¤¤¤ëÊý¸þ¤Î¾ðÊó¤ò¡¢Parameter ¤Î Look X ¤È Look Y ¤ÎÉôʬ¤ÈƱ´ü¤µ¤»¤ë¤³¤È¤¬¤Ç¤¤ì¤Ð¡¢
¥¡¼ÆþÎϤò¤½¤Î¤Þ¤Þ¥¥ã¥é¤Î°ÜÆ°¥¢¥Ë¥á¤Ë¤âŬÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¤È¤¤¤¦¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡¤³¤ì¤¬º£²ó¤Î°ÜÆ°¥¢¥Ë¥á¤È¥¥ã¥é¤Î°ÜÆ°¤È¤òƱ´ü¤µ¤»¤ë¥í¥¸¥Ã¥¯¤Ë¤Ê¤ê¤Þ¤¹¡£
¡¡¥×¥ì¥¤¥ä¡¼¥¥ã¥é¤ÎÀ©¸æ¤Ï PlayerController ¥¹¥¯¥ê¥×¥È¤Ë¤ª¤¤¤Æ¹Ô¤Ã¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢
°Ê¾å¤ÎÀ©¸æ½èÍý¤ò PlayerController ¥¹¥¯¥ê¥×¥È¤Ë¼ÂÁõ¤·¤Æ¡¢¥¥ã¥é¤Î°ÜÆ°¤È°ÜÆ°¥¢¥Ë¥á¤È¤òƱ´ü¤µ¤»¤Æ¤¤¤¤Þ¤¹¡£
¡¡º£²ó¤Ï¼ÂÁõÎã¤ò¤½¤Î¤Þ¤Þ·ÇºÜ¤·¤Æ¤¤¤Þ¤¹¤¬¡¢º£¸å¡¢¼«Ê¬¤Ç°ÜÆ°¥¢¥Ë¥á¤Ê¤É¤Î¼ÂÁõ¤ò¹Ô¤¦¾ì¹ç¤â¡¢Æ±¤¸¤è¤¦¤Ê¹Í¤¨Êý¤Ç¼ÂÁõ¤¬½ÐÍè¤Þ¤¹¡£
¤É¤Î½èÍý¤È¤É¤Î½èÍý¤¬¤Ä¤Ê¤¬¤Ã¤Æ¤¤¤ë¤Î¤«¡¢Unity ¤ÎÀ©¸æ¤ò¤É¤Î¤è¤¦¤Ë¤¹¤ì¤Ð¥¹¥¯¥ê¥×¥È¤«¤é¹Ô¤¨¤ë¤è¤¦¤Ë¤Ê¤ë¤Î¤«¡¢
À߷פιͤ¨Êý¡¢¥í¥¸¥Ã¥¯¤Îºî¤êÊý¤ò³Ð¤¨¤Æ¤¤¤Ã¤Æ¡¢¼«Ê¬¤Î¥²¡¼¥à¤Ë¤â³èÍѤǤ¤ë¤è¤¦¤Ë¤·¤Æ¤¯¤À¤µ¤¤¡£
¡¡bool ·¿¤ÎÌá¤êÃͤò»ý¤Ä¥á¥½¥Ã¥É¤Ç¤¹¡£
¡¡£²¤Ä¤Î float ÃͤòÈæ³Ó¤·¡¢¤½¤ì¤é¤¬¸ß¤¤¤Ë¾®¤µ¤ÊÃÍ (Epsilon) ¤ÎÈÏ°ÏÆâ¤Ë¤¢¤ë¾ì¹ç¤Ë true ¤ÇÊÖ¤·¤Þ¤¹¡£
¸·Ì©¤ÊÃͤǤϤʤ¯¡ÖÂçÂÎÅù¤·¤¤¤«¤É¤¦¤«¡×¤òȽÃǤ¹¤ë¤è¤¦¤Ê¥±¡¼¥¹¤ÇÍøÍѤǤ¤Þ¤¹¡£
if (!Mathf.Approximately(move.x, 0.0f) || !Mathf.Approximately(move.y, 0.0f)) { ¡¡¡¡¡¡// ½èÍý }
¡¡º£²ó¤Î¥±¡¼¥¹¤Î¾ì¹ç¡¢move.x(move.y) ¤ÎÃÍ¤È 0.0f ¤òÈæ¤Ù¤Æ¡¢move.x(move.y) ¤ÎÃͤ¬ 0.0 f ¤Ç¤Ï¤Ê¤¤¤«¡¢0.0f ¤Ë¶á¤¤ÃͤǤʤ±¤ì¤Ð¡¢false ¤Ë¤Ê¤ê¤Þ¤¹¡£
¤½¤Î¾ì¹ç¤Ë¡¢if ʸÆâ¤Î½èÍý¤¬¼Â¹Ô¤µ¤ì¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£¤Ä¤Þ¤ê¡¢¥¡¼ÆþÎϤµ¤ì¤¿Ãͤ¬ 0 ¤Ë¶á¤¤ÃͤǤʤ±¤ì¤Ð°ÜÆ°¤·¤Æ¤¤¤ë¤È¹Í¤¨¤Æ¡¢if ʸÆâ¤Î½èÍý¤ò¹Ô¤¦¤è¤¦¤Ë¤·¤Æ¤¤¤Þ¤¹¡£
¤³¤ì¤Ï float ·¿¤Î¤è¤¦¤ËºÙ¤«¤¯Æ°¤¯¡¢ÉâÆ°¾®¿ôÅÀ¤ÎÃͤξì¹ç¡¢ÆÃÄêÃÍ(0.046303f ¤Ê¤É¤ÎÃÍ)¤ò£±¤Ä¤È¤·¤Æ¸ÂÄꤹ¤ë¤³¤È¤¬Æñ¤·¤¤¤¿¤á¤Ç¤¹¡£
float ·¿¤ÎÃͤò¾ò·ï¼°¤È¤·¤ÆÈæ³Ó¤¹¤ë¾ì¹ç¤Ë¤ÏÃí°Õ¤·¤Æ¤¯¤À¤µ¤¤¡£
»²¹Í¥µ¥¤¥È
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
Mathf.Approximately
https://docs.unity3d.com/ja/current/ScriptReferenc...
Qiita @Hirai0827 ÍÍ
Á´Unity»È¤¤¤ÏMathf¤Î¥ê¥Õ¥¡¥ì¥ó¥¹¤òÆɤá
https://qiita.com/Hirai0827/items/c8bc643c0bcfe5ca...
Íõ¤Èø¡¹ ÍÍ
¡ÚUnity¡ÛÃΤäÆÆÀ¤¹¤ëMathf¥¯¥é¥¹
http://megumisoft.hatenablog.com/entry/2015/08/29/...
¡¡»ØÄꤷ¤¿ Vector2 ¹½Â¤ÂΤËÂФ·¤Æ¡¢°ú¿ô¤Ë»ØÄꤷ¤¿ x, y ¤ÎÃͤòÂåÆþ¤¹¤ë¤³¤È¤¬¤Ç¤¤ë¥á¥½¥Ã¥É¤Ç¤¹¡£
// ¸þ¤¤¤Æ¤¤¤ëÊý¸þ¤ò¹¹¿· lookDirection.Set(move.x, move.y);
¡¡½èÍýŪ¤Ë¤Ï²¼µ¤ÈƱ¤¸¤Ë¤Ê¤ê¤Þ¤¹¡£
// ¸þ¤¤¤Æ¤¤¤ëÊý¸þ¤ò¹¹¿· lookDirection = new Vector2(move.x, move.y);
¡¡Set ¥á¥½¥Ã¥É¤ÎÊý¤¬¡¢¿·¤¿¤Ë new Vector2 ¤òÀë¸À¤·¤ÆÃͤòÂåÆþ¤¹¤ë¤è¤ê¤â½èÍý¤¬Áᤤ½èÍý¤Ë¤Ê¤ê¤Þ¤¹¡£
¤Þ¤¿ Transform.position ¤ÎÂåÆþ¤Ë¤âÍøÍѤǤ¤Þ¤¹¡£
transform.position.Set(x, y, z);
»²¹Í¥µ¥¤¥È
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
Vector2.Set
https://docs.unity3d.com/ja/current/ScriptReferenc...
¥²¡¼¥à¤Îºî¤êÊý ¤ì¡¼¡÷DKRevel ÍÍ
Unity¤ÎVector3¤Î»È¤¤Êý¡Ú¥¹¥¯¥ê¥×¥È²òÀâ¡Û
https://dkrevel.com/unity-explain/vector3/
¡¡°ú¿ô¤Ë»ØÄꤷ¤¿ Vector2 ¹½Â¤ÂΤΤâ¤Ä magnitude(¥Ù¥¯¥È¥ë¤ÎÊ¿Êýº¬¤ÎŤµ) ¤ÎÃͤò 1 ¤È¤·¤¿¥Ù¥¯¥È¥ë¤òºîÀ®¤·¡¢ Vector2 ·¿¤Î¾ðÊó¤È¤·¤ÆÌᤷ¤Þ¤¹¡£
Àµµ¬²½¤µ¤ì¤¿¤È¤¥Ù¥¯¥È¥ë¤Ï¡¢Æ±¤¸Êý¸þ¤Ï°Ý»ý¤·¤¿¤Þ¤Þ¤Ç¡¢Ä¹¤µ¤¬ 1.0 ¤Î¤â¤Î¤¬ºîÀ®¤µ¤ì¤Þ¤¹¡£
¥Ù¥¯¥È¥ë¤¬¾®¤µ¤¹¤®¤ë¾ì¹ç¡¢Àµµ¬²½¤µ¤ì¤¿¤â¤Î¤Ï 0 ¥Ù¥¯¥È¥ë¤È¤·¤ÆÊÖ¤µ¤ì¤Þ¤¹¡£
// Àµµ¬²½ lookDirection.Normalize();
¡¡º£²ó¤Î¥±¡¼¥¹¤Ç¤Ï¡¢Vector2 ·¿¤Î lookDirection ÊÑ¿ô¤Î magnitude ¤ÎÃͤòÀµµ¬²½¤·¤Æ¡¢¥Ù¥¯¥È¥ë¤òºîÀ®¤·¤Æ¤¤¤Þ¤¹¡£
¤½¤Î¤¿¤á¡¢º¸¤È²¼¤ÎÊý¸þ¤Ç¤¢¤ì¤Ð -1¡¢±¦¤È¾å¤ÎÊý¸þ¤Ç¤¢¤ì¤Ð 1 ¤ÎÃͤ¬¥Ù¥¯¥È¥ë¤È¤·¤ÆºîÀ®¤µ¤ì¤Þ¤¹¡£Ãͤ¬ 0 ¤Ë¶á¤¤¾ì¹ç¤Ë¤Ï 0 ¤¬¥Ù¥¯¥È¥ë¤È¤·¤ÆºîÀ®¤µ¤ì¤Þ¤¹¡£
»²¹Í¥µ¥¤¥È
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
Vector2.Normalize
https://docs.unity3d.com/ja/current/ScriptReferenc...
¤Ñ¤Õ¤Î¼«Í³Ä¢ ÍÍ
¡ÚUnity¡Û¥Ù¥¯¥È¥ë¤òÀµµ¬²½¤¹¤ë
https://pafu-of-duck.hatenablog.com/entry/2018/02/...
¡¡Unity¤Î¥¢¥Ë¥á¡¼¥·¥ç¥ó¤Ï¡¢Animator¥¯¥é¥¹¤Ë¤è¤Ã¤ÆÍÍ¡¹¤Ê¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÀ©¸æ¤¬¹Ô¤¨¤Þ¤¹¡£
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
Animator
https://docs.unity3d.com/ja/current/ScriptReferenc...
¡¡º£²ó¤Ï¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÁ«°Ü¤Î¤¿¤á¤Ë¡¢SetFloat ¥á¥½¥Ã¥É¤òÍøÍѤ·¡¢Á«°Ü¤Î¾ò·ï¤ò¤³¤Î¥á¥½¥Ã¥É¤Î°ú¿ô¤Ë»ØÄꤷ¤Æ¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ÎÁ«°Ü¤ò¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¡¡³Æ¥á¥½¥Ã¥É¤Î°ú¿ô¤Ë¤Ï¤½¤ì¤¾¤ì·¿¤Î»ØÄ꤬°Û¤Ê¤ê¤Þ¤¹¤¬¡¢¤¤¤º¤ì¤âÂè1°ú¿ô¤Ï string ·¿¤Ç¤¹¡£¤³¤ÎÉôʬ¤Ë¤Ï¡¢¥Ñ¥é¥á¡¼¥¿¤ÇÀßÄꤷ¤¿Ê¸»úÎó¤ò»ØÄꤷ¤Þ¤¹¡£
ʸ»úÎó¤Ç¤¹¤Î¤ÇÂçʸ»ú¾®Ê¸»ú¤Ï¶èÊ̤µ¤ì¤Þ¤¹¡£¥Ñ¥é¥á¡¼¥¿¤ËÅÐÏ¿¤·¤¿Ê¸»úÎó¤ò¤³¤ÎÂè1°ú¿ô¤Ë»ØÄꤹ¤ë¤³¤È¤Ç¥Ñ¥é¥á¡¼¥¿¤Î¤â¤Ä¾ðÊó¤òÊѹ¹¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¤½¤·¤Æ¡¢¥Ñ¥é¥á¡¼¥¿¤ÎÃͤòÊѹ¹¤¹¤ëÆâÍƤòÂè2°ú¿ô¤Ë»ØÄꤷ¤Þ¤¹¡£
¡¡Î㤨¤Ð¡¢SetFloat¤Ç¤¢¤ì¤Ð¡¢Âè1°ú¿ô¤Ë float ·¿¤Î¥Ñ¥é¥á¡¼¥¿¤Ç¤¢¤ë "Look X" ¤Îʸ»úÎó¤ò»ØÄꤷ¡¢Âè2°ú¿ô¤Ë float ·¿¤ÎÃͤò»ØÄꤷ¤Þ¤¹¡£
// ¥¡¼ÆþÎϤÎÃÍ¤È Blend Tree ¤ÇÀßÄꤷ¤¿°ÜÆ°¥¢¥Ë¥áÍѤÎÃͤò³Îǧ¤·¡¢°ÜÆ°¥¢¥Ë¥á¤òºÆÀ¸ anim.SetFloat("Look X", lookDirection.x); anim.SetFloat("Look Y", lookDirection.y);
¡¡¤³¤¦¤¹¤ë¤³¤È¤Ç¡¢¤³¤Î¥Ñ¥é¥á¡¼¥¿¤ÎÃͤò¥¹¥¯¥ê¥×¥È¤«¤é½ñ¤´¹¤¨¤ë¤³¤È¤¬¤Ç¤¤Þ¤¹¡£¤½¤Î·ë²Ì¤È¤·¤Æ¡¢¾ò·ï¤¬¹çÃפ·¤¿¥¢¥Ë¥á¡¼¥·¥ç¥ó¤ËÁ«°Ü¤¹¤ë¤³¤È¤¬½ÐÍè¤Þ¤¹¡£
¥Ñ¥é¥á¡¼¥¿¤ÈSet¡Á¥á¥½¥Ã¥É¤Î´ØÏ¢À
»²¹Í¥µ¥¤¥È
Unity¸ø¼°¥¹¥¯¥ê¥×¥È¥ê¥Õ¥¡¥ì¥ó¥¹
SetFloat
https://docs.unity3d.com/ja/current/ScriptReferenc...
¡¡¥¹¥¯¥ê¥×¥ÈÆâ¤Î½èÍý¤Îή¤ì¤ò³Îǧ¤·¤Æ¤ª¤¤Þ¤·¤ç¤¦¡£
¤É¤Î¤è¤¦¤Ê¥í¥¸¥Ã¥¯¤ÇÀ©¸æ¤¬¹Ô¤ï¤ì¤Æ¤¤¤ë¤Î¤«¡¢¤·¤Ã¤«¤ê¤ÈÆâÍƤòÍý²ò¤·¤Æ¿¼¤á¤Æ¤ª¤¤¤Æ¤¯¤À¤µ¤¤¡£
¼Â¹ÔÆ°²è¡
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡¥Ò¥¨¥é¥ë¥¡¼¤Î Player ¥²¡¼¥à¥ª¥Ö¥¸¥§¥¯¥È¤òÁªÂò¤·¤Æ Animator ¥Ó¥å¡¼¤ò³Îǧ¤¹¤ë¤³¤È¤Ç
¸½ºß¤Î Animator ¤ÎÀ©¸æ¤¬¥ê¥¢¥ë¥¿¥¤¥à¤Ç³Îǧ¤Ç¤¤Þ¤¹¡£Blend Tree ¤Î Look X ¤È Look Y ¤ÎÉôʬ¤Ë
Parameter ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ë Look X ¤È Look Y ¤ÎÃͤ¬ÂåÆþ¤µ¤ì¤Æ¤¤¤ì¤ÐÀ©¸æ½ÐÍè¤Æ¤¤¤Þ¤¹¡£
¤³¤ÎÀ©¸æ¤ò Animator ¥¯¥é¥¹¤Î SetFloat ¥á¥½¥Ã¥É¤Ë¤è¤Ã¤Æ¹Ô¤Ã¤Æ¤¤¤Þ¤¹¡£
¼Â¹ÔÆ°²è¢
Æ°²è¥Õ¥¡¥¤¥ë¤Ø¤Î¥ê¥ó¥¯
¡¡°Ê¾å¤Ç¤³¤Î¼ê½ç¤Ï½ªÎ»¤Ç¤¹¡£
¡¡¼¡¤Ï¡¡¼ê½ç£±£°¡¡¡Ý¥×¥ì¥¤¥ä¡¼¥¥ã¥é¤Î°ÜÆ°ÈϰϤÎÀ©¸Â¡Ý¡¡¤Ç¤¹¡£
- ¥«¥Æ¥´¥ê¡§
- ¿Ê³Ø/¥¹¥¯¡¼¥ë
- ¥×¥í¥°¥é¥ß¥ó¥°
¥³¥á¥ó¥È¤ò¤«¤¯