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;
|
private GameObject followThis;
|
||||||
|
|
||||||
void Start() {
|
void Start() {
|
||||||
Camera.main.orthographicSize = 6;
|
Camera.main.orthographicSize = 5;
|
||||||
if ( followThis == null )
|
if ( followThis == null )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,8 @@ public class CameraControl : MonoBehaviour {
|
||||||
return;
|
return;
|
||||||
var target = followThis.transform.position;
|
var target = followThis.transform.position;
|
||||||
var targetVec = target - transform.position;
|
var targetVec = target - transform.position;
|
||||||
targetVec.z = 0;
|
targetVec.Scale(new Vector3(0.05f, 0.05f, 0));
|
||||||
Camera.main.orthographicSize = 6 + targetVec.sqrMagnitude * 10;
|
|
||||||
transform.position = transform.position + targetVec;
|
transform.position = transform.position + targetVec;
|
||||||
targetVec.Scale(new Vector3(0.05f, 0.05f, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFollow(GameObject g) {
|
public void SetFollow(GameObject g) {
|
||||||
|
|
|
@ -32,6 +32,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Vector3 speedVec = new Vector3(rb.velocity.x, rb.velocity.y, 0);
|
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;
|
float speed = speedVec.magnitude;
|
||||||
|
|
||||||
{ // Forward
|
{ // Forward
|
||||||
|
|
Loading…
Add table
Reference in a new issue