aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorCarson Katri <carson.katri@gmail.com>2021-06-13 02:06:00 -0400
committerCarson Katri <carson.katri@gmail.com>2021-06-13 02:06:00 -0400
commitac864b588ee59fbbc62c8bcf7c82cc51767276ec (patch)
tree092e3bfc54b178da080de3e77d3d957eeeeeb512
parent994202b1439fced5859d0cc7e916721f8892cb25 (diff)
downloadgmtk-gamejam-ac864b588ee59fbbc62c8bcf7c82cc51767276ec.tar.gz
gmtk-gamejam-ac864b588ee59fbbc62c8bcf7c82cc51767276ec.tar.zst
gmtk-gamejam-ac864b588ee59fbbc62c8bcf7c82cc51767276ec.zip
Add dribbling animation
-rw-r--r--Assets/Prefabs/Player.prefab8
-rw-r--r--Assets/Scenes/Main.unity2
-rw-r--r--Assets/Scripts/Controllers/GameController.cs16
3 files changed, 20 insertions, 6 deletions
diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab
index a17d9ba..c433f8b 100644
--- a/Assets/Prefabs/Player.prefab
+++ b/Assets/Prefabs/Player.prefab
@@ -180,7 +180,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
- m_IsActive: 0
+ m_IsActive: 1
--- !u!4 &4617615456759737811
Transform:
m_ObjectHideFlags: 0
@@ -189,7 +189,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 414971659141114100}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
- m_LocalPosition: {x: 0, y: -0.36000013, z: 0}
+ m_LocalPosition: {x: -0.08000004, y: -0.36000013, z: 0}
m_LocalScale: {x: 4, y: 4, z: 1}
m_Children: []
m_Father: {fileID: 5232080199619218326}
@@ -1037,7 +1037,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
- m_IsActive: 0
+ m_IsActive: 1
--- !u!4 &5036223590975315366
Transform:
m_ObjectHideFlags: 0
@@ -1046,7 +1046,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5886521033835613979}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
- m_LocalPosition: {x: -0.120000005, y: -0.36000013, z: 0}
+ m_LocalPosition: {x: -0.20000005, y: -0.36000013, z: 0}
m_LocalScale: {x: 4, y: 4, z: 1}
m_Children: []
m_Father: {fileID: 5232080199619218326}
diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity
index 5dee71b..60f743f 100644
--- a/Assets/Scenes/Main.unity
+++ b/Assets/Scenes/Main.unity
@@ -2271,6 +2271,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
freezeMotion: 0
ball: {fileID: 707826158}
+ dribbleHeight: 0.3
+ dribbleSpeed: 35
trenchCoatSegments:
- {fileID: 675960234}
- {fileID: 1613929466}
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>