make cam zoom public, fix mouse rotation

This commit is contained in:
2026-02-25 18:51:37 -06:00
parent 40201a530a
commit 41d3e38870
2 changed files with 13 additions and 8 deletions
+1 -1
View File
@@ -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;
+12 -7
View File
@@ -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);