make cam zoom public, fix mouse rotation
This commit is contained in:
@@ -7,7 +7,7 @@ public class CameraController : MonoBehaviour
|
|||||||
{
|
{
|
||||||
private bool isTracking = false; // don't track when parented
|
private bool isTracking = false; // don't track when parented
|
||||||
private bool returningHome = false; // cam is on its way home
|
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 camMovementTime = 0.9f; // how much time to switch cam positions
|
||||||
|
|
||||||
private float moveSpeed;
|
private float moveSpeed;
|
||||||
|
|||||||
@@ -103,14 +103,19 @@ void DigDetector()
|
|||||||
|
|
||||||
void RotatePlayerTowardMouse()
|
void RotatePlayerTowardMouse()
|
||||||
{
|
{
|
||||||
Vector2 positionOnScreen = Camera.main.WorldToViewportPoint(DougBody.transform.position);
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||||
Vector2 mouseOnScreen = (Vector2)Camera.main.ScreenToViewportPoint(Input.mousePosition);
|
RaycastHit hit;
|
||||||
Vector3 newRotation;
|
|
||||||
|
|
||||||
float angle = Mathf.Atan2(positionOnScreen.y - mouseOnScreen.y, positionOnScreen.x - mouseOnScreen.x) * Mathf.Rad2Deg;
|
if (Physics.Raycast(ray, out hit, Mathf.Infinity))
|
||||||
newRotation = new Vector3(0f, -(angle + 90), 0f);
|
{
|
||||||
|
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()
|
void TryInteract()
|
||||||
@@ -160,7 +165,7 @@ void HandleCamRotation()
|
|||||||
{
|
{
|
||||||
float currentY = cameraController.playerCamHome.transform.rotation.eulerAngles.y;
|
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);
|
float newY = Mathf.MoveTowardsAngle(currentY, camTargetRotation, step);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user