diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-06-12 19:37:29 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-06-12 19:37:29 -0400 |
commit | ac637ab644e3ee0c2307bc1cdb69d1f490852eeb (patch) | |
tree | 267dafda890dbc1f21d30f0ebd8758a5427070f7 | |
parent | 8c456102b340388660e4023b5c060369067033ec (diff) | |
download | gmtk-gamejam-ac637ab644e3ee0c2307bc1cdb69d1f490852eeb.tar.gz gmtk-gamejam-ac637ab644e3ee0c2307bc1cdb69d1f490852eeb.tar.zst gmtk-gamejam-ac637ab644e3ee0c2307bc1cdb69d1f490852eeb.zip |
Fix animation of ball
-rw-r--r-- | Assets/Scripts/Controllers/GameController.cs | 5 |
1 files changed, 5 insertions, 0 deletions
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<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; } |