From: Carson Katri Date: Sun, 13 Jun 2021 04:06:21 +0000 (-0400) Subject: Merge branch 'master' of git.cameronkatri.com:gmtk-gamejam X-Git-Url: https://git.cameronkatri.com/gmtk-gamejam.git/commitdiff_plain/81dfc0b51dcd0abeae7b47820f54f10050d6a678?hp=2fd846835d2460a12c321c460e77fd6026eb07a0 Merge branch 'master' of git.cameronkatri.com:gmtk-gamejam --- 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(); 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));