private void Awake() { cam = GetComponentInChildren <Camera>(); cam.transform.localPosition = new Vector3(0f, Mathf.Abs(cameraOffset.y), -Mathf.Abs(cameraOffset.x)); zoomStrategy = new OrthographicZoomStratey(cam, startingZoom); cam.transform.LookAt(transform.position + Vector3.up * looAtOffset); }
private void Awake() { lockMovement = false; cam = GetComponentInChildren <Camera>(); cam.transform.localPosition = new Vector3(0f, Mathf.Abs(cameraOffset.y), -Mathf.Abs(cameraOffset.x)); zoomStrategy = cam.orthographic ? (IZoomStrategy) new OrthographicZoomStategy(cam, startingZoom) : new PerspectiveZoomStrategy(cam, cameraOffset, startingZoom); cam.transform.LookAt(transform.position + Vector3.up * lookAtOffset); }
private void Awake() { cam = GetComponentInChildren <Camera>(); arm = cam.transform.parent; cam.transform.localPosition = new Vector3(0, cameraOffset.y, -cameraOffset.x); cam.transform.LookAt(transform.position); zoomStrategy = new PerspectiveZoomStrategy(cam, cameraOffset, startingZoom); }
private void Awake() { float y = Mathf.Abs(cameraOffset.y); float z = -Mathf.Abs(cameraOffset.x); cam = GetComponentInChildren <Camera>(); cam.transform.localPosition = new Vector3(0f, y, z); zoomStrategy = cam.orthographic ? (IZoomStrategy) new OrthographicZoomStrategy(cam, startingZoomLevel) : new PerspectiveZoomStrategy(cam, cameraOffset, startingZoomLevel); cam.transform.LookAt(transform.position + Vector3.up * lookAtOffset); }
private void Awake() { // setup camera maxBounds.x = 190; maxBounds.y = 190; cam = GetComponentInChildren <Camera>(); cam.transform.localPosition = new Vector3(0f, Mathf.Abs(cameraOffset.y), -Mathf.Abs(cameraOffset.x)); zoomStrategy = cam.orthographic ? (IZoomStrategy) new OrthographicZoomStrategy(cam, startingZoom) : new PerspectiveZoomStrategy(cam, cameraOffset, startingZoom); cam.transform.LookAt(transform.position + Vector3.up * lookAtOffset); // initial camera position initialPosition = transform.position; initialRotation = transform.rotation; }
private void LateUpdate() { // reset camera position if (Input.GetKey(KeyCode.Space)) { transform.SetPositionAndRotation(initialPosition, initialRotation); zoomStrategy = cam.orthographic ? ((IZoomStrategy) new OrthographicZoomStrategy(cam, startingZoom)) : new PerspectiveZoomStrategy(cam, cameraOffset, startingZoom); } if (frameMove != Vector3.zero) { Vector3 speedModFrameMove = new Vector3(frameMove.x * lateralSpeed, frameMove.y, frameMove.z * inOutSpeed); transform.position += transform.TransformDirection(speedModFrameMove) * Time.deltaTime; LockPositionInBounds(); frameMove = Vector3.zero; } if (frameZoom < 0f) { zoomStrategy.ZoomIn(cam, Time.deltaTime * Mathf.Abs(frameZoom) * zoomSpeed, nearZoomLimit); frameZoom = 0f; } if (frameZoom > 0f) { zoomStrategy.ZoomOut(cam, Time.deltaTime * frameZoom * zoomSpeed, farZoomLimit); frameZoom = 0f; } if (frameRotate != 0f) { transform.RotateAround(new Vector3(95f, 0f, 95f), new Vector3(0, 1f, 0), frameRotate * Time.deltaTime * rotateSpeed); frameRotate = 0f; } }