// Update is called once per frame void Update() { //Check how much should camera move distanceToMove = thePlayer.transform.position.x - lastPlayerPosition.x; //Actual move of camera if ((thePlayer.transform.position.y > transform.position.y * 5f) && !thePlayer.grounded) { transform.position = new Vector3(transform.position.x, transform.position.y * 3f, transform.position.z); } if (thePlayer.grounded) { transform.position = new Vector3(transform.position.x, lastCameraPosition.y, transform.position.z); } transform.position = new Vector3(transform.position.x + distanceToMove, transform.position.y, transform.position.z); //Check where is Player now lastPlayerPosition = thePlayer.transform.position; if (thePlayer.transform.position.y - offset > thePlatformGenerator.getMaxHeight()) { cam.orthographicSize += zoomOutSpeed * Time.deltaTime; cam.orthographicSize = Mathf.Clamp(cam.orthographicSize, minZoom, maxZoom); } if (thePlayer.transform.position.y - offset < thePlatformGenerator.getMaxHeight()) { cam.orthographicSize -= zoomInSpeed * Time.deltaTime; cam.orthographicSize = Mathf.Clamp(cam.orthographicSize, minZoom, maxZoom); } }