diff options
author | Carson Katri <carson.katri@gmail.com> | 2021-06-13 00:06:21 -0400 |
---|---|---|
committer | Carson Katri <carson.katri@gmail.com> | 2021-06-13 00:06:21 -0400 |
commit | 81dfc0b51dcd0abeae7b47820f54f10050d6a678 (patch) | |
tree | c98c828949e5c3d6a2ce2f19709a4285f25ab7bb /Assets/Scripts/Controllers/AIController.cs | |
parent | 2fd846835d2460a12c321c460e77fd6026eb07a0 (diff) | |
parent | 20e5bf4339ffe52b6b09c7b72413c1e2295e282a (diff) | |
download | gmtk-gamejam-81dfc0b51dcd0abeae7b47820f54f10050d6a678.tar.gz gmtk-gamejam-81dfc0b51dcd0abeae7b47820f54f10050d6a678.tar.zst gmtk-gamejam-81dfc0b51dcd0abeae7b47820f54f10050d6a678.zip |
Merge branch 'master' of git.cameronkatri.com:gmtk-gamejam
Diffstat (limited to 'Assets/Scripts/Controllers/AIController.cs')
-rw-r--r-- | Assets/Scripts/Controllers/AIController.cs | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/Assets/Scripts/Controllers/AIController.cs b/Assets/Scripts/Controllers/AIController.cs index ad258f3..cdfc9a8 100644 --- a/Assets/Scripts/Controllers/AIController.cs +++ b/Assets/Scripts/Controllers/AIController.cs @@ -27,6 +27,7 @@ namespace Controllers private Rigidbody2D _rigidbody; private float animationStep; + private bool turn; public BoxCollider2D BoxCollider => _boxCollider != null ? _boxCollider : _boxCollider = GetComponent<BoxCollider2D>(); private BoxCollider2D _boxCollider; @@ -77,7 +78,6 @@ namespace Controllers // transform.position += new Vector3(game.ball.transform.position.x - transform.position.x, 0f, 0f).normalized * (Time.deltaTime * speed); var direction = Vector2.MoveTowards(transform.position, game.ball.transform.position, speed * Time.deltaTime); transform.position = new Vector2(direction.x, transform.position.y); - flipper.localScale = new Vector3((Vector2.Distance(transform.position, direction) > 0 ? -1f : 1f), 1, 1); } } else // Otherwise, move toward the basket, and then once we get within range, take the shot. @@ -89,6 +89,13 @@ namespace Controllers } movement -= transform.position; + + bool currentTurn = movement.x > 0; + if (turn && currentTurn) + flipper.transform.localScale = new Vector3(1f, 1f, 1f); + else + flipper.transform.localScale = new Vector3(-1f, 1f, 1f); + turn = currentTurn; game.enemy.Move(transform.position + new Vector3(0f, BoxCollider.size.y * 3/4, 0f)); |