private void LateUpdate() { Vector3 pos = mapCamera.position; Quaternion rot = mapCamera.rotation; float fov = mapCamera.fieldOfView; if (panoramaAmount > 0) { pos = Vector3.Lerp(pos, panoramaPos, panoramaAmount); rot = Quaternion.Slerp(rot, GyroUtility.GyroRotation(), Mathf.Pow(panoramaAmount, 6)); fov = Mathf.Lerp(fov, PANORAMA_FOV, Mathf.Pow(panoramaAmount, 6)); } transform.position = pos; transform.rotation = rot; cam.fieldOfView = fov; }
private void Update() { // Update UI gpsText.text = "Location Service:" + System.Environment.NewLine + Input.location.status; // Retrieve information from the device's sensors float latitude = ARCoordinateUtility.LAT_ORIGIN; float longitude = ARCoordinateUtility.LON_ORIGIN; float compass = 0; Quaternion gyro = Quaternion.identity; if (Input.location.status == LocationServiceStatus.Running) { latitude = Input.location.lastData.latitude; longitude = Input.location.lastData.longitude; compass = Input.compass.trueHeading; gyro = GyroUtility.GyroRotation(); } // Move the user based on their GPS position, placing them on top of any colliders Vector3 targPos = ARCoordinateUtility.LatLonToPosition(latitude + ox, longitude + oy); Ray ray = new Ray(targPos + Vector3.up * 100, Vector3.down); RaycastHit hit; if (Physics.Raycast(ray, out hit, 200)) { targPos = hit.point; } transform.position = Vector3.Lerp(transform.position, targPos, 0.1f); // Rotate the camera by combining the gyro and compass readings heading = Mathf.LerpAngle(heading, compass, 0.2f); Vector3 facingVec = gyro * Vector3.forward; Vector3 yawVec = Vector3.ProjectOnPlane(facingVec, Vector3.up); float pitch = Vector3.Angle(facingVec, yawVec) * (facingVec.y < 0 ? 1 : -1); cam.rotation = Quaternion.Euler(pitch, heading, 0); }