ãUnity2ããã¬ã¤ã¤ã¼ã移åï¼Input.mousePosition, ScreenToWorldPointããããã¯å´©ã3ã
Unityãã¼ã¸ã§ã³ï¼5.0.0f4 Personal (2015/4/23)
Â
ååã®ç¶ããæ¸ãã¦ããã¾ãã
ä»åã¯ããã¬ã¤ã¤ã¼ãåããã¾ãããï¼
Â
ãç®æ¨ããã¬ã¤ã¤ã¼ãåããã²ã¼ã ãç¶ç¶ãããï¼
Â
ããã¤ãåããã¾ããã
Â
ã課é¡ï¼ããã¬ã¤ã¤ã¼ãåãã
ãã¬ã¤ã¤ã¼ãåããscriptãä½ã£ã¦ãè²¼ãä»ãã¾ãããã
Â
Â
Input.mousePositionã«ãã£ã¦ãã¹ã¯ãªã¼ã³åº§æ¨ï¼ãã¦ã¹ãç¾å¨ããä½ç½®ãã¹ããã ã£ããã¿ããããä½ç½®ï¼ãåå¾ã§ãã¾ãã試ãã«Input.mousePositionã®ä¸ã®è¡ã«ãDebug.Log(pos);ãã¨ããã³ã¼ãã追å ãã¦ãããã°ãã¦ã¿ãã¨ãããç»é¢ã®å·¦ä¸ã(x:0, y:0)ã§ãå³ä¸ã(x:æå¤§å¤ y:æ大å¤)ã¨ãªã£ã¦ããããã§ãã
Â
ãã®ã¹ã¯ãªã¼ã³åº§æ¨ãã¯ã¼ã«ã座æ¨ï¼Transform.Positionçã§ä»ã¾ã§åéãè¨å®ãã¦ããä½ç½®æ å ±ï¼ã«å¤æããã®ãã Camera.main.ScreenToWorldPoint()ã§ãã
ãã£ãã®ä¸ã«å¼æ°ã¨ãã¦ã¹ã¯ãªã¼ã³åº§æ¨ï¼posï¼ãå ¥ãããã¨ã§ãã¯ã¼ã«ã座æ¨ã«å¤æãã¦ããã¾ãã
Â
å¤æããã¯ã¼ã«ã座æ¨ãæå¾ã®è¡ã§ãã¬ã¼ã¤ã¼ä½ç½®ã«å¤æãã¦ãã¾ããããã®åã«x.y.zã®ä½ç½®ã調æ´ãã¦ãã¾ãã
Â
ä»åãã¬ã¤ã¤ã¼ã¯æ¨ªç§»åããã®ã§ãx軸以å¤ã¯åºå®ã§ãã
Â
x軸ã«é¢ãã¦ã¯ãå£ãçªãæããªãããã«èª¿æ´ãã¾ããããåã®å ´åã¯å·¦ç«¯ã-2.1fãå³ç«¯ã2.1fã§ã¡ããã©ããæãã«ãªãã¾ããã
Â
æ¢ã¾ã£ã¦ããã¾ããè·³ãè¿ãã¦ããã¾ã
Â
ããã¾ããBGMãé³´ãã
ãªãã¨ãªãã²ã¼ã ã£ã½ãé°å²æ°ã«ãªã£ã¦ããã®ã§ãé³æ¥½ãé³´ããã¾ãããã
Â
GANSAIBOW CREATE EVERYDAY!æ§ã®è¨äºã«ããã¨ãUnityã§ã¯aif,wav,mp3,oggã¨ããå½¢å¼ããµãã¼ããã¦ãããä¸ã§ãoggå½¢å¼ã®ãã®ãæ¨å¥¨ãã¦ããããã§ãã
Â
ã¾ãã¯oggå½¢å¼ã®é³æºãã¡ã¤ã«ãasset storeã§è½ã¨ããªãèªåã§é²é³ãããªããã¦ãæã«ããã¾ãããã
Â
ããã¦Main Cameraã®InspectorããAdd Component>Audio>AudioSourceã¨é²ã¿ãAudioSourceããã£ã¤ãã¾ãããã
Â
AudioSourceãiPodããã¦ã©ã¼ã¯ãã³ããã¨ãã£ãé³æ¥½åçã®ã¤ã¡ã¼ã¸ãããã¦ãã®ä¸ã«ããAudioListenerã人éã§ããè³ã«ãããã¾ãã
Â
MainCameraã«ã¤ããAudioSourceã®AudioClipã«ãå ã»ã©æã«å ¥ããBGMããã£ã¤ãã¾ããã¾ããã«ã¼ãåçããããã¨æãã¾ãã®ã§ãLoopã«ãã§ãã¯ãå ¥ããã®ããå¿ããªãã
Â
é³æ¥½ãé³´ãããã«ãªãã¾ãã
Â
ãã¦ä»åã¯ããã¾ã§ã¨ãªãã¾ãããããã¨ããããã¾ããã
Â