aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Assets/Scripts/Controllers/GameController.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Controllers/GameController.cs')
-rw-r--r--Assets/Scripts/Controllers/GameController.cs16
1 files changed, 14 insertions, 2 deletions
diff --git a/Assets/Scripts/Controllers/GameController.cs b/Assets/Scripts/Controllers/GameController.cs
index 6faf2dd..926238a 100644
--- a/Assets/Scripts/Controllers/GameController.cs
+++ b/Assets/Scripts/Controllers/GameController.cs
@@ -27,6 +27,10 @@ namespace Controllers
/// The single ball for the game.
/// </summary>
[SerializeField] public Ball ball;
+
+ [SerializeField] private float dribbleHeight;
+ [SerializeField] private float dribbleSpeed;
+ private Vector3 ballTarget;
[SerializeField] public SpriteRenderer[] trenchCoatSegments;
@@ -86,7 +90,7 @@ namespace Controllers
freezeMotion = false;
startTime = Time.time;
- ball.Rigidbody.AddForce(new Vector2(0f, 10f));
+ ball.Rigidbody.velocity = new Vector2(0, 5f);
}
private void Update()
@@ -94,6 +98,14 @@ namespace Controllers
UpdateUI();
}
+ private void FixedUpdate()
+ {
+ if (player.HasBall || enemy.HasBall)
+ {
+ ball.transform.position = ballTarget - new Vector3(0, Mathf.Sin(Time.time * dribbleHeight * dribbleSpeed) + 1f, 0);
+ }
+ }
+
private bool gameover;
private void UpdateUI()
{
@@ -160,7 +172,7 @@ namespace Controllers
public void Move(Vector2 handPosition)
{
if (controller.state == (isEnemy ? State.EnemyDribble : State.PlayerDribble)) // Make sure they're dribbling.
- controller.ball.transform.position = handPosition; // TODO: Make this perform a dribbling motion, otherwise it looks like they're travelling.
+ controller.ballTarget = handPosition;
}
/// <summary>