5 public class CameraController : MonoBehaviour
7 [SerializeField] private Transform target;
8 [SerializeField] private float speed;
9 [SerializeField] private GameController game;
11 private void FixedUpdate()
13 if (game.player.IsShooting || game.enemy.IsShooting) // Track the ball when they shoot
14 transform.position = Vector3.MoveTowards(transform.position, new Vector3(game.ball.transform.position.x, game.ball.transform.position.y, -10f), Time.deltaTime * speed);
15 else // Track the player otherwise
16 transform.position = Vector3.MoveTowards(transform.position, new Vector3(target.transform.position.x, target.transform.position.y, -10f), Time.deltaTime * speed);