Camera zoom
This commit is contained in:
parent
79d4fe7ba5
commit
ad4ebd46d3
2 changed files with 3 additions and 4 deletions
|
@ -8,7 +8,7 @@ public class CameraControl : MonoBehaviour {
|
|||
private GameObject followThis;
|
||||
|
||||
void Start() {
|
||||
Camera.main.orthographicSize = 6;
|
||||
Camera.main.orthographicSize = 5;
|
||||
if ( followThis == null )
|
||||
return;
|
||||
}
|
||||
|
@ -18,10 +18,8 @@ public class CameraControl : MonoBehaviour {
|
|||
return;
|
||||
var target = followThis.transform.position;
|
||||
var targetVec = target - transform.position;
|
||||
targetVec.z = 0;
|
||||
Camera.main.orthographicSize = 6 + targetVec.sqrMagnitude * 10;
|
||||
targetVec.Scale(new Vector3(0.05f, 0.05f, 0));
|
||||
transform.position = transform.position + targetVec;
|
||||
targetVec.Scale(new Vector3(0.05f, 0.05f, 0));
|
||||
}
|
||||
|
||||
public void SetFollow(GameObject g) {
|
||||
|
|
|
@ -32,6 +32,7 @@ public class PlayerMovement : MonoBehaviour {
|
|||
return;
|
||||
|
||||
Vector3 speedVec = new Vector3(rb.velocity.x, rb.velocity.y, 0);
|
||||
Camera.main.orthographicSize = Camera.main.orthographicSize * 0.95f + (5 + 4f/6f * (speedVec.magnitude)) * 0.05f;
|
||||
float speed = speedVec.magnitude;
|
||||
|
||||
{ // Forward
|
||||
|
|
Loading…
Add table
Reference in a new issue