using UnityEngine; public class CameraFollow : MonoBehaviour { public Vector3 MiddlePosition; [Header ("Player Targets")] public GameObject[] targets; [Header ("Follow Settings")] public float distanceToTarget = 10; // The distance to the target public float heightOffset = -2; // the height offset of the camera relative to it's target public float viewAngle = -6; //a downwards rotation public Vector3 AdditionalOffset; //any additional offset public bool FollowZAxis; //enable or disable the camera following the z axis [Header ("Damp Settings")] public float DampX = 3f; public float DampY = 2f; public float DampZ = 3f; [Header ("View Area")] public float MinLeft; public float MaxRight; [Header ("Wave Area collider")] public bool UseWaveAreaCollider; public BoxCollider CurrentAreaCollider; public float AreaColliderViewOffset; private bool firstFrameActive; void Start(){ UpdatePlayerTargets(); firstFrameActive = true; } void Update () { if (targets.Length > 0){ MiddlePosition = Vector3.zero; if(targets.Length == 1){ //follow a single target if(targets[0] != null) MiddlePosition = targets[0].transform.position; } else { //find center position between multiple targets int count = 0; for(int i=0; i