ãUnity1ãã¦ããã£ã¡ãããMain Cameraã追ãï¼Mathf.Lerpãã¦ããã£ã¡ãã縦ã¹ã¯ãã¼ã«4ã
Unity5.1.1f1 Personal(2015å¹´6æ)
Â
ãã®ã³ã³ãã³ãã¯ããã¦ããã£ã¡ããã©ã¤ã»ã³ã¹ãã§æä¾ããã¦ãã¾ã
Â
ååã®ç¶ããæ¸ãã¦ããã¾ãã
Â
ãã£ã©ã¯ã¿ã¼ã®èªåã¹ã¯ãã¼ã«ãå£è¡çªæå転ãã¹ãã¼ã¹ãã¼ã§ã¸ã£ã³ãã»ã»ã»åãã¯ã ãã¶æ´ã£ã¦ãã¾ããã
Â
é©å½ã«è¶³å ´ãä½ã£ã¦ãã©ãã©ãä¸ã¸ç»ã£ã¦ããã²ã¼ã ã«ãããã®ã§ããããã®ããã«ã¯ã«ã¡ã©ã§ãã£ã©ã¯ã¿ã¼ã追ããããªããã°ãªãã¾ãããã®ã§ãä»åã¯ãã®æ©è½ãå®è£ ãã¾ãã
Â
ã«ã¡ã©ã®å¦çãå®è£ ããåã«ãCube(å£)ãã³ãã¼ãã¦ä¸¡ãµã¤ãã«é ç½®ãCube(åº)ãã³ãã¼ãããµã¤ãºãæ´ãã¦ã²ã¼ã ç»é¢ä¸ã«ããã¤ãé ç½®ãã¦ããã¾ãã
Â
å£ã¨åºãã³ãã¼ãã¦é ç½®
Â
 ãç®æ¨ããã£ã©ã¯ã¿ã¼ãMain Cameraã«è¿½ããããããï¼
Â
â ãã£ã©ã¯ã¿ã¼ãä¸ã«åããæã«ãã«ã¡ã©ãé£åãã¦ä¸ã«åãï¼
ãã£ã©ã¯ã¿ã¼ã®é«ãæ å ±(ã¦ããã£ã¡ããã®gameObject.transform.position.y)ãåå¾ãã¦ãã«ã¡ã©ã®é«ãæ å ±(MainCameraã®GameObject.transform.position.y)ã«ä»£å ¥ããã°ããããã§ãã
Â
â¡ãã£ã©ã¯ã¿ã¼ãä¸ã«è½ã¡ãæã¯ãã«ã¡ã©ãåããªã
ifæã§ã«ã¡ã©ã®é«ããããã¬ã¤ã¤ã¼ã®é«ãã®ã»ãã大ãããªã£ãæã ããâ ã®å¦çãå®è¡ããã°ããããã§ãã
Â
ããã§ã¯ä»¥ä¸ã®CameraScriptãä½æãã¦ãMain Cameraã«ã¨ãã¤ãã¦ä¸ããã
Â
Â
 Mathf.Lerpã¯éã®å¤ãåãã¾ããä»åã®å ´åã¯ãã¬ã¤ã¤ã¼ã®é«ãã¨ç¾å¨ã®ã«ã¡ã©ã®é«ãã®ã0.5ãªã®ã§ã¡ããã©ä¸éããnewHeightã¨ãã¦ãã¾ãã
Â
newHeightã決å®ãããã¨ãã¬ã¤ã¤ã¼ã®é«ãã¨ç¾å¨ã®ã«ã¡ã©ã®é«ããæ¯è¼ãã¦ããã¬ã¤ã¤ã¼ã®é«ãã®ã»ãã大ãããã°newHeightãMain Cameraã®æ°ããªé«ãã¨ãã¦æå®ãã¾ãã
Â
ä¸éå¤ãã¨ãâæ¡ä»¶ãæºããããMain Cameraã®é«ãã移åããã
Â
ãçµæãÂ
ã«ã¡ã©ããã£ã©ã¯ã¿ã¼ã追ãããã
Â
Â
ããã§ã¯ä»åã¯ããã¾ã§ã§ãã
ãããã¨ããããã¾ããã
Â