diff --git a/Assets/Scripts/Projectile.cs b/Assets/Scripts/Projectile.cs index 1077140..612f3f9 100644 --- a/Assets/Scripts/Projectile.cs +++ b/Assets/Scripts/Projectile.cs @@ -97,13 +97,20 @@ public class Projectile : MonoBehaviour float angleX = (_destinationX) / _initialXDistance; float angleY = (_destinationY) / _initialYDistance; - Debug.Log("Angle X: " + angleX); Debug.Log("Angle Y: " + angleY); + Debug.Log("Angle X: " + angleX); if(angleY >= 1 || angleY <= -1) { - float lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY); - //TODO: Determiner les angles x et y que la fleche doit prendre selon l'angle qu'elle est tiree. + //TODO: L'angle fonctionne mieux, mais il y a toujours des problemes avec les angles pret de X + //ou ils sont beaucoup trop verticaux. + float lerpStepS; + if(angleX > 0.24 || angleX < -0.24) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY); + + else if(angleX > 0.09 || angleX < -0.09) lerpStepS = -Mathf.Rad2Deg * Mathf.Atan(angleY / angleX); + + else lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleY / angleX); + float angleS = Mathf.Lerp(lerpStepS, 0, 0); transform.eulerAngles = new Vector3(0, 0, angleS); }