Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e99156177b | ||
|
|
8891b70641 | ||
|
|
d8e0b5fa80 | ||
|
|
bb50976229 | ||
|
|
a38633b581 |
@@ -19,7 +19,7 @@ public class CameraController : MonoBehaviour
|
||||
}
|
||||
|
||||
pivot.position = player.position;
|
||||
pivot.parent = player.transform;
|
||||
pivot.parent = null;
|
||||
|
||||
Cursor.visible = !Cursor.visible;
|
||||
Cursor.lockState = CursorLockMode.Locked;
|
||||
@@ -27,7 +27,7 @@ public class CameraController : MonoBehaviour
|
||||
|
||||
void LateUpdate(){
|
||||
float camX = Input.GetAxisRaw("Mouse X") * rotateSpeed;
|
||||
player.Rotate(0, camX, 0);
|
||||
pivot.Rotate(0, camX, 0);
|
||||
|
||||
float camY = Input.GetAxisRaw("Mouse Y") * rotateSpeed;
|
||||
if (invertY){
|
||||
@@ -36,6 +36,12 @@ public class CameraController : MonoBehaviour
|
||||
pivot.Rotate(-camY, 0, 0);
|
||||
}
|
||||
|
||||
if(Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
player.Rotate(0, camX, 0);
|
||||
pivot.Rotate(0, 0, 0);
|
||||
}
|
||||
|
||||
if(pivot.rotation.eulerAngles.x > maxViewAngle && pivot.rotation.eulerAngles.x < 180f)
|
||||
{
|
||||
pivot.rotation = Quaternion.Euler(maxViewAngle, 0, 0);
|
||||
@@ -47,18 +53,21 @@ public class CameraController : MonoBehaviour
|
||||
}
|
||||
|
||||
float camZ = Input.GetAxisRaw("Mouse ScrollWheel");
|
||||
|
||||
float angleY = pivot.eulerAngles.y;
|
||||
float angleX = pivot.eulerAngles.x;
|
||||
float angleY = player.eulerAngles.y;
|
||||
float cameraAngle = transform.eulerAngles.y;
|
||||
|
||||
//if (Mathf.Abs(cameraAngle - angleY) <= 45){ Potential start for camera following similar to banjo/mario64
|
||||
/* Code to force the camera behind the player
|
||||
if(Input.GetKey(KeyCode.LeftShift))
|
||||
{
|
||||
angleY = player.eulerAngles.y;
|
||||
angleX = player.eulerAngles.x;
|
||||
} */
|
||||
|
||||
float cameraAngle = transform.eulerAngles.y;
|
||||
|
||||
Quaternion rotation = Quaternion.Euler(angleX, angleY, 0);
|
||||
transform.position = player.position - (rotation * offset);
|
||||
|
||||
//}
|
||||
|
||||
if(transform.position.y < player.position.y){
|
||||
transform.position = new Vector3(transform.position.x, player.position.y - 0.5f, transform.position.z);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user