OSCã§ãªã¢ã«ã¿ã¤ã ã³ã³ããã¼ã« in VRChat - æ¦èª¬ç·¨
ã¯ããã«
ååãOSCã¡ãã»ã¼ã¸ãããªã¬ã¼ã¨ãã¦ä½¿ç¨ããæ¹æ³ã説æãã¾ããã jscmla1118.hatenablog.com
ããã«è¨è¼ããéããå¿ç¨æ¬¡ç¬¬ã§ã¯ä¸è¨ã®ãããªç §æã³ã³ããã¼ã©ãä½æãããã¨ãã§ãã¾ãã
ç¾å®ãããªã¢ã«ã¿ã¤ã ã§èªç±ã«æä½ã§ãããVRChatåãã®ç §æãå®è£ ãã¾ããï¼MIDIã³ã³ããã¼ã©çµç±ã§ãè²åããæãããå¾ããå¤æ´ã§ãã¾ããã¾ã ã¾ã 試ä½æ®µéã ãã©ãVRChatä¸ã§ã®åç»ä½æããèå°æ¼åºãªããã«å¿ç¨åºæ¥ãããª...ï¼ pic.twitter.com/DCTfujAYcw
— ãããã@VRChat (@jscmla1118) 2018å¹´10æ13æ¥
ä»åã¯ãVRChatå´ã®è¨å®ã主ã¨ãã¦ãç §æã³ã³ããã¼ã«ã®åºæ¬ã¨ãªãä»çµã¿ã«ã¤ãã¦èª¬æãã¾ãã ã¾ãã¯åºæ¬çãªåããæ´ããããVRChatä¸ã®èªä½ã¯ã¼ã«ãã«è¨ç½®ããCubeã®èµ¤è²ãèªç±ã«å¤ããæ¹æ³ãä¾ã¨ãã¦èª¬æãã¾ãã ãã¸ãã¯ã¯ãããå¿ç¨ãã¦ãããã®ãªã®ã§ããã®è¨äºãèªãã§ããããã°å¤§ä½ã®æµãã¯æ´ããã¨æãã¾ãã
éä¿¡å´
ã¾ãå§ãã«ãOSCã¡ãã»ã¼ã¸ã®éä¿¡å´ã«ã¤ãã¦ã説æãã¾ãã éä¿¡å´ã§æå®ããã®ã¯ãåæ ããããè²æ å ±ã§ãã ä»åã®ä¾ã§ã¯èµ¤è²ã®ã¿ãæ±ãã®ã§ãRGBã®Rå¤ã対象ã«èª¬æãã¾ãã ã¾ããRå¤ã¯0~255ã®10é²æ°ã§æå®ãããã¨ãåæã¨ãã¾ãã
ãã¦ãä¾ãã°ãCubeãªãã¸ã§ã¯ãã®èµ¤è²ãR180ã«ããããã¨ãã¾ãããã éä¿¡å´ã§æåã«å ¥åããå¤ã¯ããã®180ã¨ãã10é²æ°ã®æ°å¤ã§ãã æçµçã«VRChatã¸éä¿¡ããã®ã¯ãOSCã¡ãã»ã¼ã¸ã§ãã ãã®OSCã¡ãã»ã¼ã¸ã§ãããã©ããªå¤ãéã£ãã¨ãã¦ãVRChatã«ã¦å¤å®ã§ããã®ã¯On/Offã®ã¿ã§ãã ãã®ããã1ã¤ã®OSCã¡ãã»ã¼ã¸ã ãã§Rå¤ã表ç¾ãããã¨ã¯ã§ãã¾ããã
ã§ã¯ãã©ã®ããã«æ°å¤ãæ±ãã®ãã¨ããã¨ã2é²æ°è¡¨è¨ã使ç¨ãã¾ãã
2é²æ°ã¯åæ¡ã0ã1ã§è¡¨ç¾ããæ¹æ³ã§ãè¨ãæããã°ã¹ã¤ããã®On/Offã«å¯¾å¿ããããã¾ãã
ããããRå¤ã®0~255ã¨ããæ°å¤ã¯ã赤è²ã®æ度ã1Byte(8Bit)ã®æ°å¤ãããªãã¡8æ¡ã®2é²æ°ã§è¡¨ç¾ãããã®ã§ãã
åæ¡ã«å¯¾å¿ããOSCã¡ãã»ã¼ã¸ã8ã¤éä¿¡ãããããå
ã®10é²æ°ã«ããå¤æã§ããã°ãOn/Offããå©ç¨ã§ããªãVRChatä¸ã§ãRå¤ã表ç¾ã§ããã¨ããããã§ãã
åä¿¡å´
éä¿¡å´ã®èª¬æã¯ç°¡åã«æ¸ã¾ãã¤ã¤ãåä¿¡å´ã®å¦çã«ã¤ãã¦ã¯ç´°ãã追ã£ã¦ããã¾ãã
ãªãã¸ã§ã¯ããã©ã¡ã¼ã¿ã®å¤æ´æ¹æ³
ã¾ãã¯ãVRChatã«ã¦ã©ã®ããã«ãã¦ãªãã¸ã§ã¯ãã®è²ãå¤ããã®ããèãã¦ã¿ã¾ãã é常ãUnityã§ä½æããã¢ããªã±ã¼ã·ã§ã³ãªããC#ã¹ã¯ãªãããããªãã¸ã§ã¯ãã®ãã©ã¡ã¼ã¿ãåç §ãã¦å¤æ´ããã®ããä¸è¬çãªæ段ãã¨æãã¾ãã ããããVRChatã«ã¯èªä½ã®C#ã¹ã¯ãªãããæã¡è¾¼ããã¨ãã§ããªãã®ã§ããã®æ¹æ³ã¯ä½¿ç¨ã§ãã¾ããã ã¨ãªã£ãã¨ããä»ã®æ段ã¨ãã¦æãããããã®ã®1ã¤ãã¢ãã¡ã¼ã·ã§ã³ã§ãã ã¢ãã¡ã¼ã·ã§ã³ã¯ããªãã¸ã§ã¯ãã®ãã©ã¡ã¼ã¿ãä¸æçã«å¤æ´ã§ãã¾ãã åçãçµãã£ããå ã«æ»ãã®ãåºæ¬çãªã¢ãã¡ã¼ã·ã§ã³åä½ã§ã¯ããã¾ãããçµäºç¶æ ãç¶æãããã¨ãã§ãã¾ãã VRChatä¸ã§ã¯ããã®ã¢ãã¡ã¼ã·ã§ã³ã®æ§è³ªãå©ç¨ãã¦Cubeãªãã¸ã§ã¯ãã®è²ãå¤ãã¾ãã
VRChatããªã¬ã¼ã¨ã¢ãã¡ã¼ã·ã§ã³
次ã«ãOSCã¡ãã»ã¼ã¸ã®åä¿¡ãããªã¬ã¼ã¨ãã¦ãã¢ãã¡ã¼ã·ã§ã³ã«ã¢ã¯ã·ã§ã³ãä¸ããæ¹æ³ãèãã¾ãã VRChat SDKã«ã¦å®ç¾©ããã¦ããã¢ãã¡ã¼ã·ã§ã³é¢é£ã®ããªã¬ã¼ã¯ã以ä¸ã®ãã®ãããã¾ãã
- AnimationBool
- AnimationFloat
- AnimationInt
- AnimationTrigger
- AnimationIntAdd
- AnimationIntDivide
ãããå
¨ã¦ãã¢ãã¡ã¼ã·ã§ã³ãã©ã¡ã¼ã¿ãæä½ããããªã¬ã¼ã§ãã
ãã®ãã©ã¡ã¼ã¿ã¯ã¢ãã¡ã¼ã·ã§ã³å®è¡ã®é¾å¤ã¨ãã¦ä½¿ç¨ããããã®ã§ããè¨å®ããå¤ãä¸å®ã®ç¯å²ã«å
¥ã£ãããã¢ãã¡ã¼ã·ã§ã³ãåçãããã¨ãããããªä½¿ãæ¹ãã§ãã¾ãã
ããã«è¨å®ããå¤ããã®ã¾ã¾ã¢ãã¡ã¼ã·ã§ã³ã«åæ ã§ããã°ããã®ã§ãããæ®å¿µãªãããã®æ¹æ³ã¯ãªãããã§ãã
ããã«å«ã¾ãã¦ããã"AnimationBool"ã¯On/Offãåããã©ã¡ã¼ã¿ã§ãã ãã®On/OffããOSCã¡ãã»ã¼ã¸ããåãåã£ãOn/Offã«å¯¾å¿ããã¦ä½¿ç¨ãã¾ãã
ã¢ãã¡ã¼ã·ã§ã³ã«ãããã©ã¡ã¼ã¿æä½
次ã«èãããã¨ã¯ãã¢ãã¡ã¼ã·ã§ã³ã§è²ãå¤åãããæ¹æ³ã§ãã
ããã¯Unityã«æ
£ãã¦ããæ¹ãªãç°¡åãªè©±ã§ãCubeãªãã¸ã§ã¯ãã®ã¡ãã·ã¥ã«å®ç¾©ããã¦ããColorãã©ã¡ã¼ã¿ãå¤åãããã°ããã§ãã
ä¾ãã°ãCubeãªãã¸ã§ã¯ãã®èµ¤è²ãR128ã«å¤æ´ããå ´åãã¾ã0~255ã®ç¯å²ã0~1ã«æ£è¦åãã¾ã("128"ãæ£è¦åããå ´åã¯ã"0.5"ã«ãªãã¾ã)ã
ããã«åºã¥ãã"Color.r"ãã©ã¡ã¼ã¿ã0ãã0.5ã«å¤åãããã¢ãã¡ã¼ã·ã§ã³ã¯ãªãããè¨å®ãã¾ãã
ãã®ã¢ãã¡ã¼ã·ã§ã³ã¯ãªããã§ãããçµäºç¶æ
ãç¶æããå¿
è¦ãããã®ã§Loop Timeã¯ãã§ãã¯ãå¤ãã¦ãã ããã
è¨å®ãå®äºããããä¸è¨ã®ã¢ãã¡ã¼ã·ã§ã³ã¯ãªãããå«ãã¢ãã¡ã¼ã·ã§ã³ã³ã³ããã¼ã©ãä½æãã¾ãã
ããã¦ãAnimationBoolã®On/Offã«å¿ãã¦ã¢ãã¡ã¼ã·ã§ã³ã¯ãªãããåç/åæ¢ãããããã«é·ç§»ãå®ç¾©ããã°ãè²ãå¤ãããã¨ãã§ãã¾ãã
OSCã¡ãã»ã¼ã¸ã®å¾©å·
Cubeãªãã¸ã§ã¯ãã®è²ãæä½ããæ¹æ³ã¯ãã£ããç解ã§ãããã¨æãã¾ãã ã¨ã¯ãããã®ã®ãVRChatã«ã¦åä¿¡ããOSCã¡ãã»ã¼ã¸ã¯ãä»åã®ã±ã¼ã¹ã§ã8ã¤ããã¾ãã ããããã©ã¡ã¼ã¿ã使ç¨ããã¨ãã¦ãã©ã®ãããªã¢ãã¡ã¼ã·ã§ã³ã§Cubeã®è²ã«åæ ãããã°ããã®ã§ããããã
1ã¤èããããæ¹æ³ã¯ã255åã®ã¢ãã¡ã¼ã·ã§ã³ã¯ãªãããç¨æãããã©ã¡ã¼ã¿ã«åºã¥ãã¦255ãã¿ã¼ã³ã«é·ç§»ãããæ¹æ³ã§ãã
ã§ããããã®æ¹æ³ã§ã¯æéãããããããã®ã§ãé¸æè¢ããã¯é¤å¤ããããå¾ã¾ããã
ã§ã¯ã©ãããã®ãã¨ããã¨ã2é²æ°ãã10é²æ°ã«å¤æããæ¹æ³ãå¿ç¨ããã°ããã®ã§ãã
2é²æ°ã®åæ¡ã¯ãä¸è¨ã®ãããª10é²æ°ã«å¯¾å¿ããããã¾ãã
ããã¯2é²æ°ã10é²æ°ã«å¤æããä¸è¬çãªæ¹æ³ã§ãç®åºãããæ°å¤ããã¹ã¦è¶³ãåãããã¨å
ã«æ»ãã¾ãã
ãã®å ´åã 128+32+16+4=180 ã¨ããããã«ãéä¿¡å´ã®æ°å¤ã«æ»ããã¨ãã§ãã¾ãã
æ¹ãã¦ãã¢ãã¡ã¼ã·ã§ã³ã®è©±ã«æ»ãã¾ãã Unityã®ã¢ãã¡ã¼ã·ã§ã³ã³ã³ããã¼ã©ã¼ã§ã¯ãã¢ãã¡ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ãè¨å®ã§ãã¾ãã ããã使ç¨ããã¨ãã¢ãã¡ã¼ã·ã§ã³ãéãåããããè¨ãæããã°è¶³ãåããããã¨ãã§ãã¾ãã ä½ãè¨ããããã¨ããã¨ãRå¤ã128ã ãå¤æ´ããã¢ãã¡ã¼ã·ã§ã³ã«å ãã¦ã64, 32, 16...ã ãå¤åãããã¢ãã¡ã¼ã·ã§ã³ãéãåããã¦ããã°ãçµã¿åãã次第ã§Rå¤ã0ãã255ã¾ã§èªç±ã«å¤åãããããããã«ãªãã¾ãã
ã¢ãã¡ã¼ã·ã§ã³ã¬ã¤ã¤ã¼ã¯ãAnimatorã¿ãã«ã¦è¿½å ã§ãã¾ãã
ã¢ãã¡ã¼ã·ã§ã³ãéãåãããã¨ãã«ã¯ããã®ã¬ã¤ã¤ã¼ã«ã¦Weightã"1"ãBlendingã"Additive"ã«è¨å®ãã¾ãã
8ã¤ã®OSCã¡ãã»ã¼ã¸ã«å¯¾å¿ããè¤æ°ã®ã¬ã¤ã¤ã¼ã¨ãã©ã¡ã¼ã¿ãç¨æãããã¨ã«ãªãã¾ãããã¢ãã¡ã¼ã·ã§ã³ã®é·ç§»ã¯å
¨ã¦åãããã«è¨å®ããã°ããã§ãã
ã¾ããåºè»¸ã¨ãªããªãã»ããã¢ãã¡ã¼ã·ã§ã³ãç¨æãã¾ãã
ãã¡ãã¯Blendingã"Override"ã«è¨å®ãã¾ãã
ããã§ãã¢ãã¡ã¼ã·ã§ã³ãã©ã¡ã¼ã¿ã®On/Offã«å¿ãã¦è²ãèªç±ã«å¤ããããããã«ãªãã¾ãã
ãããã®ã¢ãã¡ã¼ã·ã§ã³ãã©ã¡ã¼ã¿ã¯å
ã«èª¬æããéãOSCã¡ãã»ã¼ã¸ã§å
¨ã¦ã¹ã¤ããã³ã°å¯è½ãªã®ã§ãçµæçã«OSCã¡ãã»ã¼ã¸ãéãã¦Cubeãªãã¸ã§ã¯ãã®è²ãèªç±ã«å¤æ´ã§ããããã«ãªãã¾ãã
ãããã«
ããã¾ã§ãOSCã¡ãã»ã¼ã¸ã使ç¨ãã¦ãCubeãªãã¸ã§ã¯ãã®èµ¤è²ãå¤æ´ããä¸éãã®æµãã説æãã¾ããã ãã®å¿ç¨ã ãã§ãç §æã³ã³ããã¼ã«ãã»ã¼å®ç¾ã¯ã§ãã¾ãã ãªããªããç §æã³ã³ããã¼ã«ã®å ´åã¯ãè²ã«å ãã¦ç §æãªãã¸ã§ã¯ãã®ä½ç½®ãè§åº¦ãåãããã«æä½ããã°ããã ããªã®ã§ãã ä»ã«ããã¢ãã¡ã¼ã·ã§ã³ã¯ãªããããæä½ã§ãããã©ã¡ã¼ã¿ã§ããã°åãæ¹æ³ã§æä½ã§ããã¯ããªã®ã§ããããªãã«å¿ç¨ãå©ããã¨æãã¾ãã ã¨ã¯ãããã®ã®ãããã¤ã工夫ãå¿ è¦ãªé ç®ãããã®ã§ã詳細ã«ã¤ãã¦ã¯å¥è¨äºãæ¸ããã¨æãã¾ãã ã¾ããç¾ç¶ã®æ¹æ³ã§ã¯ãã¾ãã¡ä½¿ãåæãæªãã®ã§ãèªåã§è¨å®å¯è½ãªæ¡å¼µã¨ãã£ã¿ãä½æãããã¨æã£ã¦ãã¾ãã Unityã«ã¤ãã¦ã¯ãããããªã®ã§æéããããããã§ãããå®æãããé å¸ãã¾ãã