From ac637ab644e3ee0c2307bc1cdb69d1f490852eeb Mon Sep 17 00:00:00 2001 From: Cameron Katri Date: Sat, 12 Jun 2021 19:37:29 -0400 Subject: Fix animation of ball --- Assets/Scripts/Controllers/GameController.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs index de3b00c..e1af95c 100644 --- a/Assets/Scripts/Controllers/GameController.cs +++ b/Assets/Scripts/Controllers/GameController.cs @@ -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(); } 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; } -- cgit v1.2.3-56-ge451