X-Git-Url: https://git.cameronkatri.com/gmtk-gamejam.git/blobdiff_plain/1b91ab39bdde7cf2a2b68472ae30a76b48311aa5..HEAD:/Assets/Scripts/Controllers/CameraController.cs diff --git a/Assets/Scripts/Controllers/CameraController.cs b/Assets/Scripts/Controllers/CameraController.cs index 7d42be5..8730c1c 100644 --- a/Assets/Scripts/Controllers/CameraController.cs +++ b/Assets/Scripts/Controllers/CameraController.cs @@ -6,10 +6,14 @@ namespace Controllers { [SerializeField] private Transform target; [SerializeField] private float speed; + [SerializeField] private GameController game; private void FixedUpdate() { - transform.position = Vector3.MoveTowards(transform.position, new Vector3(target.transform.position.x, target.transform.position.y, -10f), Time.deltaTime * speed); + if (game.player.IsShooting || game.enemy.IsShooting) // Track the ball when they shoot + transform.position = Vector3.MoveTowards(transform.position, new Vector3(game.ball.transform.position.x, game.ball.transform.position.y, -10f), Time.deltaTime * speed); + else // Track the player otherwise + transform.position = Vector3.MoveTowards(transform.position, new Vector3(target.transform.position.x, target.transform.position.y, -10f), Time.deltaTime * speed); } } }