]> git.cameronkatri.com Git - gmtk-gamejam.git/commitdiff
Finally fix shooting
authorCarson Katri <carson.katri@gmail.com>
Sun, 13 Jun 2021 03:01:15 +0000 (23:01 -0400)
committerCarson Katri <carson.katri@gmail.com>
Sun, 13 Jun 2021 03:01:15 +0000 (23:01 -0400)
Assets/Scenes/Main.unity
Assets/Scripts/Controllers/AIController.cs
Assets/Scripts/Controllers/Ball.cs
Assets/Scripts/Controllers/GameController.cs
Assets/Scripts/Controllers/Player/PlayerController.cs

index adf97a59e1553eb652598db8440a70182dc4dc84..1b228c2b4a358a57b5cdb39fdb81a671674982f2 100644 (file)
@@ -595,7 +595,7 @@ Camera:
   m_Enabled: 1
   serializedVersion: 2
   m_ClearFlags: 2
-  m_BackGroundColor: {r: 0.3584906, g: 0.3584906, b: 0.3584906, a: 0}
+  m_BackGroundColor: {r: 0.10588236, g: 0.10588236, b: 0.11764707, a: 0}
   m_projectionMatrixMode: 1
   m_GateFitMode: 2
   m_FOVAxisMode: 0
@@ -702,6 +702,10 @@ PrefabInstance:
   m_Modification:
     m_TransformParent: {fileID: 0}
     m_Modifications:
+    - target: {fileID: 2510945038599774573, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
+      propertyPath: m_Mass
+      value: 0.1
+      objectReference: {fileID: 0}
     - target: {fileID: 4042332068071005264, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
       propertyPath: m_Name
       value: Ball
@@ -752,7 +756,7 @@ PrefabInstance:
       objectReference: {fileID: 0}
     - target: {fileID: 6267610020350316690, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
       propertyPath: shotForce
-      value: 500
+      value: 8
       objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: 2485406c33a7d4f5481ce936cc9b162e, type: 3}
@@ -1059,6 +1063,10 @@ PrefabInstance:
       propertyPath: m_Name
       value: Enemy
       objectReference: {fileID: 0}
+    - target: {fileID: 7079067999241254397, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
+      propertyPath: m_IsActive
+      value: 1
+      objectReference: {fileID: 0}
     m_RemovedComponents: []
   m_SourcePrefab: {fileID: 100100000, guid: d9b5414ac39834728992e2585c5ad778, type: 3}
 --- !u!4 &961513381 stripped
index bd5fee1165aa96ccae8544d59a124c94d9551f4c..9d3d77b1dc4632693a3b546f0da857e6c0234fb8 100644 (file)
@@ -53,9 +53,9 @@ namespace Controllers
       if (!game.enemy.HasBall) return;
       var hoopDistance = Mathf.Abs(transform.position.x - game.EnemyHoop.transform.position.x);
       var playerHoopDistance = Mathf.Abs(player.root.transform.position.x - game.EnemyHoop.transform.position.x);
-      if (hoopDistance < 6f && hoopDistance > 2.5f && (Random.Range(0, 100) > 30 || playerHoopDistance > hoopDistance)) // Take the shot when in range. 70% chance he decides to if the player is standing between him and the basket.
+      if (hoopDistance < 10.5f && hoopDistance > 2.5f && (Random.Range(0, 100) > 30 || playerHoopDistance > hoopDistance)) // Take the shot when in range. 70% chance he decides to if the player is standing between him and the basket.
       {
-        game.enemy.Shoot(transform, 0f);
+        game.enemy.Shoot(transform, Random.Range(0.5f, 1f));
       }
     }
 
@@ -82,7 +82,7 @@ namespace Controllers
       {
         // How far the enemy tries to get from the hoop before shooting.
         // Currently, it will try to shoot a 3pt. shot if down, but a 2pt. shot if up or tied.
-        var targetDistance = game.enemy.score < game.player.score ? 5f : 3f;
+        var targetDistance = game.enemy.score < game.player.score ? 10f : 4f;
         transform.position = new Vector2(Vector2.MoveTowards(transform.position, game.EnemyHoop.transform.position + new Vector3(targetDistance, 0, 0), speed * Time.deltaTime).x, transform.position.y);
       }
 
index 936b857e1b83ed4aca69ede6e99699aa6530d760..ae0656f3a6022e0e13a9446485c56129d529ca87 100644 (file)
@@ -1,5 +1,3 @@
-using System;
-using System.Net.Mime;
 using UnityEngine;
 
 namespace Controllers
@@ -20,11 +18,10 @@ namespace Controllers
       controller.BallDropped();
     }
 
-    public void Shoot(Vector3 target, float time)
+    public void Shoot(Hoop target, float time)
     {
-      transform.right = target - transform.position;
-      Rigidbody.velocity = Vector2.zero;
-      Rigidbody.AddForce((transform.right + (transform.up * 0.5f)) * (shotForce * ((Mathf.Clamp(time, 0f, 1f) + 1))));
+      transform.localRotation = Quaternion.identity;
+      Rigidbody.velocity = (Vector2)((target.transform.position - transform.position).normalized + transform.up * Mathf.Clamp(time, 0f, 1f)) * shotForce;
     }
   }
 }
index ce6ea7ea2a2becf7a9404e4adef7b964e2b2fa66..9fbe6742b9a8d1f950f4a890d4e57e4fed0c22cd 100644 (file)
@@ -144,7 +144,7 @@ namespace Controllers
         controller.dribbleSound.Stop();
         controller.state = shoot;
         controller.ball.Rigidbody.bodyType = RigidbodyType2D.Dynamic;
-        controller.ball.Shoot(hoop.transform.position, time);
+        controller.ball.Shoot(hoop, time);
         lastShotPosition = playerTransform.position;
         return true;
       }
index 1360b6cf997f915bb36ac31b972a30ff9e1688f4..d72b077cdbdcfdf7864119b60c60233c961046d7 100644 (file)
@@ -103,7 +103,7 @@ namespace Controllers.Player
         ShootStartTime = Time.time;
 
       if (Input.GetKeyUp(controls.shoot))
-        game.player.Shoot(segments.Last().transform, ShootStartTime - Time.time);
+        game.player.Shoot(segments.Last().transform, Time.time - ShootStartTime);
     }
     
     [Serializable]