From b98eeb70aa92599d9dc875fb85697f60dc3e97d7 Mon Sep 17 00:00:00 2001 From: MaximilienBlanchardBizien1 Date: Fri, 30 May 2025 16:22:19 -0400 Subject: [PATCH] Projectile Code Cleanup Cleaned up the "Projectile.cs" file to remove personal comments and attempted solution to fixing the issue of units not being able to shoot arrows backward. --- Assets/Scripts/Projectile.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Projectile.cs b/Assets/Scripts/Projectile.cs index 41420bd..c87fae9 100644 --- a/Assets/Scripts/Projectile.cs +++ b/Assets/Scripts/Projectile.cs @@ -76,7 +76,7 @@ public class Projectile : MonoBehaviour } float x = _speedTime; - float y = x >= 0 ? (_angle*-Mathf.Pow(x, 2) + _destinationX * x) : - (_angle * -Mathf.Pow(x, 2) + _destinationX * x); + float y = (_angle*-Mathf.Pow(x, 2) + _destinationX * x) transform.position = new Vector2(_initialX + x*_angle, _initialY + y); @@ -100,18 +100,12 @@ public class Projectile : MonoBehaviour float angleX = (_destinationX) / _initialXDistance; float angleY = (_destinationY) / _initialYDistance; - //Obtenir difference entre la position Y du chateau et de l'enemie. + //Obtenir la difference entre la position Y du chateau et de l'enemie. float diffY = transform.position.y - _enemyPosY; - //Debug.Log("Angle X: " + angleX); - if (diffY >= 0.1 || diffY <= -0.1) { - //TODO: L'angle fonctionne mieux, mais il y a toujours des problemes avec les angles pret de X - //ou ils sont beaucoup trop verticaux. - //L'angle a l'air de fonctionner lorsqu'il tire en avant (X positif), mais on dirait qu'il y a un probleme - //lorsque X est negatif. - //TODO: Recalculer la vitesse pour qu'elle fonctionne lorsque le projectile est tire en arriere. + float lerpStepS; if (angleX > 0.23) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY);