// Move wand each frame private void MoveWand() { // Transform input direction based on camera forward float spd = speed * Time.deltaTime; Vector3 moveDirection = Camera.main.transform.forward; moveDirection.y = 0; float x = PanInputs.WandX(); float z = PanInputs.WandZ(); moveDirection = Vector3.Normalize(moveDirection); // Don't normalize your inputs Vector3 moveDirectionF = moveDirection * z; // Project z onto forward direction vector Vector3 moveDirectionR = new Vector3(moveDirection.z, 0, -moveDirection.x); // Create right vector moveDirectionR *= x; // Project x onto right direction vector moveDirection = moveDirectionF + moveDirectionR; moveDirection *= spd; // Update move timer if (x != 0 || z != 0) { moveTime = 0; } // Apply move direction to transform transform.Translate(moveDirection.x, 0, moveDirection.z); // Limit movement LimitWandPosition(); }
// Take a screenshot and save it private void ScreenCapture() { if (PanInputs.ScreenCapture()) { string filePath = Application.dataPath + "/Screenshots/"; string fileName = "Screenshot_" + garden.gardenName + System.DateTime.Now.ToString("_yyyy-MM-dd-HH-mm-ss") + ".png"; if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } screenshotText.text = "Screenshot saved as " + fileName; screenshotTime = 0f; UnityEngine.ScreenCapture.CaptureScreenshot(filePath + fileName); } screenshotUI.SetActive(screenshotTime <= screenshotCooldown && screenshotTime > 0.05f); }
void LateUpdate() { // Don't move camera if in menu if (!cameraInWandMode) { return; } // Update camera position based on mouse movement x += PanInputs.CameraX() * xSpeed * 0.02f; y -= PanInputs.CameraY() * ySpeed * 0.02f; x = (x + 360f) % 360f; y = Mathf.Clamp(y, yMinLimit, yMaxLimit); Quaternion rotation = Quaternion.Euler(y, x, 0); distance = Mathf.Clamp(distance - PanInputs.CameraZoom() * distanceSpeed, distanceMin, distanceMax); Vector3 negDistance = new Vector3(0.0f, 0.0f, -distance); Vector3 position = rotation * negDistance + wand.position; transform.rotation = rotation; transform.position = position; }