diff --git a/Assets/Scripts/CameraControl.cs b/Assets/Scripts/CameraControl.cs index 811ec68..2bc2d87 100644 --- a/Assets/Scripts/CameraControl.cs +++ b/Assets/Scripts/CameraControl.cs @@ -7,26 +7,27 @@ public class CameraControl : MonoBehaviour { [SerializeField] private GameObject followThis; - private Vector3 offset; - void Start() { + Camera.main.orthographicSize = 6; if ( followThis == null ) return; - offset = transform.position - followThis.transform.position; } void LateUpdate() { if ( followThis == null ) return; - var target = followThis.transform.position; // + offset; + var target = followThis.transform.position; var targetVec = target - transform.position; - targetVec.Scale(new Vector3(0.05f, 0.05f, 0)); - + targetVec.z = 0; + Camera.main.orthographicSize = 6 + targetVec.sqrMagnitude * 10; transform.position = transform.position + targetVec; + targetVec.Scale(new Vector3(0.05f, 0.05f, 0)); } public void SetFollow(GameObject g) { followThis = g; - offset = transform.position - followThis.transform.position; + var diff = (transform.position - followThis.transform.position); + diff.Scale(new Vector3(1f, 1f, 0f)); + transform.position = transform.position - diff + (Vector3) (Random.insideUnitCircle) * Random.value * 5f; } } \ No newline at end of file