diff options
author | Cameron Katri <me@cameronkatri.com> | 2021-06-13 12:25:28 -0400 |
---|---|---|
committer | Cameron Katri <me@cameronkatri.com> | 2021-06-13 12:25:28 -0400 |
commit | 1b91ab39bdde7cf2a2b68472ae30a76b48311aa5 (patch) | |
tree | 689cb0b25e7e01005ad6abddaf2befaaf6412e6b | |
parent | ce6e15a6488476e8e490cb4a43f4591c266835cb (diff) | |
download | gmtk-gamejam-1b91ab39bdde7cf2a2b68472ae30a76b48311aa5.tar.gz gmtk-gamejam-1b91ab39bdde7cf2a2b68472ae30a76b48311aa5.tar.zst gmtk-gamejam-1b91ab39bdde7cf2a2b68472ae30a76b48311aa5.zip |
Only shoot if you have the ball
-rw-r--r-- | Assets/Scripts/Controllers/Player/PlayerController.cs | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/Assets/Scripts/Controllers/Player/PlayerController.cs b/Assets/Scripts/Controllers/Player/PlayerController.cs index e555bec..191c970 100644 --- a/Assets/Scripts/Controllers/Player/PlayerController.cs +++ b/Assets/Scripts/Controllers/Player/PlayerController.cs @@ -103,20 +103,22 @@ namespace Controllers.Player } } - // Try shooting the ball if pressed. - if (Input.GetKeyDown(controls.shoot)) - { - ShootStartTime = Time.time; - progressBarContainer.SetActive(true); - } + if (game.player.HasBall) { + // Try shooting the ball if pressed. + if (Input.GetKeyDown(controls.shoot)) + { + ShootStartTime = Time.time; + progressBarContainer.SetActive(true); + } - progressBar.transform.localScale = new Vector3(0.75f * Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f), 0.05f, 1f); - // progressBar.transform.localPosition = new Vector3(0.75f * (1 - Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f)), 0f, 0f); + progressBar.transform.localScale = new Vector3(0.75f * Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f), 0.05f, 1f); + // progressBar.transform.localPosition = new Vector3(0.75f * (1 - Mathf.Clamp(Time.time - ShootStartTime, 0f, 1f)), 0f, 0f); - if (Input.GetKeyUp(controls.shoot)) - { - game.player.Shoot(segments.Last().transform, Time.time - ShootStartTime); - progressBarContainer.SetActive(false); + if (Input.GetKeyUp(controls.shoot)) + { + game.player.Shoot(segments.Last().transform, Time.time - ShootStartTime); + progressBarContainer.SetActive(false); + } } } |