1
0
Fork 0

Camera zoom

This commit is contained in:
Piegames 2018-04-23 14:25:21 +02:00
parent 79d4fe7ba5
commit ad4ebd46d3
2 changed files with 3 additions and 4 deletions

View file

@ -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) {

View file

@ -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