From 41d3e388706e5d02c99d55fb7426cb5523c1a331 Mon Sep 17 00:00:00 2001 From: Trey Shaw Date: Wed, 25 Feb 2026 18:51:37 -0600 Subject: [PATCH] make cam zoom public, fix mouse rotation --- Assets/Scripts/CameraController.cs | 2 +- Assets/Scripts/PlayerController.cs | 19 ++++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/Assets/Scripts/CameraController.cs b/Assets/Scripts/CameraController.cs index 607425e..3a7191c 100644 --- a/Assets/Scripts/CameraController.cs +++ b/Assets/Scripts/CameraController.cs @@ -7,7 +7,7 @@ public class CameraController : MonoBehaviour { private bool isTracking = false; // don't track when parented private bool returningHome = false; // cam is on its way home - private float baseCamSize = 7; // this is how "zoomed" the ortho cam is + public float baseCamSize = 7; // this is how "zoomed" the ortho cam is private float camMovementTime = 0.9f; // how much time to switch cam positions private float moveSpeed; diff --git a/Assets/Scripts/PlayerController.cs b/Assets/Scripts/PlayerController.cs index 782092b..3597805 100644 --- a/Assets/Scripts/PlayerController.cs +++ b/Assets/Scripts/PlayerController.cs @@ -103,14 +103,19 @@ void DigDetector() void RotatePlayerTowardMouse() { - Vector2 positionOnScreen = Camera.main.WorldToViewportPoint(DougBody.transform.position); - Vector2 mouseOnScreen = (Vector2)Camera.main.ScreenToViewportPoint(Input.mousePosition); - Vector3 newRotation; + Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); + RaycastHit hit; - float angle = Mathf.Atan2(positionOnScreen.y - mouseOnScreen.y, positionOnScreen.x - mouseOnScreen.x) * Mathf.Rad2Deg; - newRotation = new Vector3(0f, -(angle + 90), 0f); + if (Physics.Raycast(ray, out hit, Mathf.Infinity)) + { + Vector3 targetPosition = hit.point; + targetPosition.y = transform.position.y; - DougBody.transform.rotation = Quaternion.Euler(newRotation); + Vector3 direction = targetPosition - transform.position; + Quaternion targetRotation = Quaternion.LookRotation(direction, Vector3.up); + + DougBody.transform.rotation = targetRotation; + } } void TryInteract() @@ -160,7 +165,7 @@ void HandleCamRotation() { float currentY = cameraController.playerCamHome.transform.rotation.eulerAngles.y; - float step = 150 * Time.deltaTime; + float step = 200 * Time.deltaTime; float newY = Mathf.MoveTowardsAngle(currentY, camTargetRotation, step);