]> git.cameronkatri.com Git - gmtk-gamejam.git/blobdiff - Assets/Scripts/Controllers/CameraController.cs
Add VFX
[gmtk-gamejam.git] / Assets / Scripts / Controllers / CameraController.cs
index 7d42be5d3a5d3303b30e24c7593b4229576adefa..8730c1cbbdca560e74287bef6f6a18ba7787dc2f 100644 (file)
@@ -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);
     }
   }
 }