]> git.cameronkatri.com Git - gmtk-gamejam.git/blobdiff - Assets/Scripts/Controllers/CameraController.cs
Add VFX
[gmtk-gamejam.git] / Assets / Scripts / Controllers / CameraController.cs
index faffbe5f45e0bd9f8fb7d38faf1f76e1bf414b79..8730c1cbbdca560e74287bef6f6a18ba7787dc2f 100644 (file)
@@ -6,10 +6,14 @@ namespace Controllers
   {
     [SerializeField] private Transform target;
     [SerializeField] private float speed;
+    [SerializeField] private GameController game;
 
-    private void Update()
+    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);
     }
   }
 }