ãUnity1ãã©ã³ãã ã§è¶³å ´ãèªåçæï¼Prefab, Instantiateãã¦ããã£ã¡ãã縦ã¹ã¯ãã¼ã«11ã
Unity5.1.1f1 Personal(2015å¹´6æ)
Â
ãã®ã³ã³ãã³ãã¯ããã¦ããã£ã¡ããã©ã¤ã»ã³ã¹ãã§æä¾ããã¦ãã¾ã
Â
ååã®ç¶ãã§ãã
Â
é·ããã¨ãã¥ã¼ããªã¢ã«ã«ãä»ãåãé ããããã¨ããããã¾ãããããã§ã¦ããã£ã¡ãã横ã¹ã¯ãã¼ã«ã¢ã¯ã·ã§ã³2Dã¯æå¾ã®è¨äºã«ãªãã¾ãã
Â
ä»åã¯ã©ã³ãã ã§è¶³å ´ãèªåçæãããã¨æãã¾ãã
 ãç®æ¨ãã©ã³ãã ã§è¶³å ´ãèªåçæããï¼
Â
â è¶³å ´ãPrefabåãã
ã¾ãã¯ååä½æããStepãªãã¸ã§ã¯ããPrefabåãã¾ããPrefabã«ã¤ãã¦ã¯ä¸è¨ã¨ãã»ã³ã¹ã«è©³ããã¾ã¨ãã¦ããã¾ãã®ã§ããåç §ä¸ããã
Â
 Â
Prefabsãã©ã«ããä½æããStepãªãã¸ã§ã¯ãããã©ãã°ï¼ãããããã¦ä¸ããã
Â
ãã©ãã°ï¼ããããï¼
Â
Prefabãã©ã«ãã«ã³ãã¼ããGround1ãHierarchyã«ãã©ãã°ï¼ããããããã°ãããããã®Prefabãçæã§ãã¾ãã
Â
åæã®è¶³å ´ã¨ãã¦5åç¨é ç½®ãã¦ããã¾ãããã
Â
Prefabãé©å½ã«é ç½®
Â
â¡è¶³å ´ãèªåçæãã
ç¶ãã¦è¶³å ´ãèªåçæãã¾ãããã
Â
ã¹ã³ã¢ãå ¥ãã©ã¤ã³ãscoreUpPosã¨ããå¤æ°ã§å®ç¾©ãã¦ãããã¨ãè¦ãã¦ãã¾ãã§ãããããï¼éå»è¨äºããåç §ä¸ããã
Â
Â
CameraScriptã§è¨å®ããã¦ããscoreUpPosãè¶ ããæãã²ã¼ã ç»é¢ãä¸ã«ã¯ã¿åºããä½ç½®ã«ãè¶³å ´ãï¼ã¤ãã¤çæãã¦ããã¾ãããã
Â
çæããã®ã¯å ã»ã©ä½æããStepãã¬ãã¡ãã§ãã以ä¸ã½ã¼ã¹ã§ãã
Â
Â
publicå¤æ°ã¨ãã¦stepã宣è¨ãã¦ããã¾ãã®ã§ãPrefabã®Stepãæå®ãã¦ããã¾ãããã
Â
ãã©ãã°ï¼ããããï¼
Â
scoreUpPosãè¶ ãããã¨ã«ãCreateStepã¡ã½ãããå¼ã³åºããè¶³å ´ãçæãã¦ããã¾ãã
Â
Prefabãçæããã«ã¯Instantiateã¨ããè¨è¿°ãè¡ãã¾ãã第1å¼æ°ã«ã¯publicå¤æ°ã«ã¦å®ç¾©ããStepãã¬ãã¡ããæå®ãã¾ãã
Â
第2å¼æ°ã«ã¯ä½ç½®æ å ±ã¨ãã¦Vector2ãæå®ãã¾ããVector2ã®xã«ã¯çæ¹ã¯-6.0ã0fãããçæ¹ã«ã¯0fã6.0fãæå®ãããã¨ã«ãããã¹ãã¼ã¸ã®å·¦å³ã«ã©ã³ãã ã«è¶³å ´ãçæãã¦ãã¾ããæ´ã«ãyã®ã»ãã«ã¯gatePointã«4.0fã6.0fã®æ°ã足ããå¤ãè¨å®ãããã¨ã§ãããã©ã³ãã ãªæãã«ãã¦ããã¾ãã
Â
第ï¼å¼æ°ã¯å¾ããæå®ãã¾ãããä»åã¯step.transform.rotationã¨ããPrefabã®å¾ãããã®ã¾ã¾æå®ããç¹ã«å¾ãã¾ããã
Â
ããããã§ãã©ã³ãã ã«è¶³å ´ãçæãããã¨ãã§ãã¾ããï¼
Â
è¶³å ´ãã©ãã©ãä½ããã¦ããã¾ã
Â
â¢å£ãèªåçæãã
ãã¨ã¯å£ãèªåçæããã°ãã²ã¼ã ããã£ã¨ç¶ãããã«ãªãã¾ãã
Â
Unityã¡ããã®é«ããy軸ã§ããã¨ããã®10ãè¶ ããæãã²ã¼ã ç»é¢ããã¯è¦ããªãä½ç½®ã«å£ãçæãã¦ããã¾ãããã以ä¸ã½ã¼ã¹ã§ãã
Â
Â
å ã»ã©ã¯scoreUpPosã§è¶³å ´ãçæãã¦ãã¾ããããä»åã¯createWallPosã¨ããå¤æ°ãæ°ãã«ä½æããåãè¦é ã§å£ãä½ãç¶ãã¦ãã¾ãã
Â
å ã»ã©ã¨åãè¦é ã§å£ãPrefabåãã
Â
ãã©ãã°ï¼ããããï¼
Â
ãã¬ãã¡ãããæåã®å£ãçæãã¦ããã
Â
ãã©ãã°ï¼ããããï¼ï¼
Â
Wallãã¬ãã¡ããCameraScriptã«è¨å®ãã¾ãï¼
Â
ãã©ãã°ï¼ããããï¼ï¼ï¼
Â
â£è¦ããªããªã£ããªãã¸ã§ã¯ããåé¤ãã
ãªãã¸ã§ã¯ãã®æ°ã¯å°ãªãã»ããã²ã¼ã ã®åä½ã軽ããªãã¾ãã®ã§ãç»é¢ããè¦ããªããªã£ããªãã¸ã§ã¯ãã¯åé¤ãã¦ãã¾ãã¾ãããã
Â
ã¾ãã¯è¶³å ´ã®åé¤ãGroundScriptã«è¿½è¨ãã¾ãããã
Â
Â
FindWithTagã«ããMainCameraãã¿ã°ããæ¤ç´¢ãã¦åå¾ããè¶³å ´ã®é«ããMainCameraã®é«ããã6ãå¼ããä½ç½®ãããä¸ã«ãããDestroyãã¦ããã¾ãã
Â
ç¶ãã¦å£ã«ãDestroyWallScriptãä½æãWallãã¬ãã¡ãã«åãä»ãã¾ãã以ä¸ã½ã¼ã¹ã§ãã
Â
Â
ãã¡ããMainCameraãã¿ã°ã§åå¾ããå£ãåºã®é«ããMainCameraã®é«ããã20ãå¼ããä½ç½®ãããä¸ã«ãããDestroyãã¦ããã¾ãã
Â
ãçµæã
ããããã²ã¼ã ãå®æè´ãã¾ããã
Â
ã¿ã¤ãã«ç»é¢ã
Â
ã¿ããããã¨ã²ã¼ã ãã¯ãã¾ã
Â
ã¸ã£ã³ãã§å¾ç¹ã稼ã
Â
ä¸ã«è½ã¡ããã²ã¼ã ãªã¼ãã¼
Â
ã¿ãããã¦ã¿ã¤ãã«ç»é¢ã¸
Â
Â
é·ããã¨ãããã¨ããããã¾ããã以ä¸ã§ã¦ããã£ã¡ãã縦ã¹ã¯ãã¼ã«ã¢ã¯ã·ã§ã³ã®ãã¥ã¼ããªã¢ã«ã¯çµããã§ãã
ä»å¾ã¨ãã©ãããããããé¡ãè´ãã¾ãã
Â