]> git.cameronkatri.com Git - gmtk-gamejam.git/commitdiff
Fix animation of ball
authorCameron Katri <me@cameronkatri.com>
Sat, 12 Jun 2021 23:37:29 +0000 (19:37 -0400)
committerCameron Katri <me@cameronkatri.com>
Sat, 12 Jun 2021 23:37:29 +0000 (19:37 -0400)
Assets/Scripts/Controllers/GameController.cs

index de3b00c5479281f2570d782190d821062a657645..e1af95c970789c8767aa192dd1ac2afbd11fe7d4 100644 (file)
@@ -9,6 +9,7 @@ namespace Controllers
   public class GameController : MonoBehaviour
   {
     private State state = State.JumpBall; // A basketball game always starts with a jump ball.
+    internal Animator BallAnimation;
 
     public Player player;
     public Player enemy;
@@ -30,6 +31,7 @@ namespace Controllers
       ball.controller = this;
       PlayerHoop.controller = this;
       EnemyHoop.controller = this;
+      BallAnimation = ball.GetComponentInChildren<Animator>();
     }
     
     public struct Player
@@ -90,6 +92,7 @@ namespace Controllers
         if (Vector2.Distance(controller.ball.transform.position, handPosition) >= 1f) return false;
         
         controller.state = dribble;
+        controller.BallAnimation.enabled = false;
         controller.dribbleSound.Play();
         Move(handPosition);
         return true;
@@ -103,6 +106,7 @@ namespace Controllers
       public bool Shoot(Transform playerTransform)
       {
         if (controller.state != dribble) return false; // We must be dribbling the ball to shoot it.
+        controller.BallAnimation.enabled = true;
         controller.dribbleSound.Stop();
         controller.state = shoot;
         controller.ball.Shoot(hoop.transform.position);
@@ -113,6 +117,7 @@ namespace Controllers
 
     internal void BallDropped()
     {
+      BallAnimation.enabled = true;
       dribbleSound.Stop();
       state = State.Idle;
     }