Flèches droites peuvent changer d'angle #7

Merged
MaximilienBB merged 8 commits from origin/feature/StraightArrowChangesAngle into main 2025-05-30 23:42:35 +00:00
Showing only changes of commit d454865a24 - Show all commits

View File

@ -97,13 +97,20 @@ public class Projectile : MonoBehaviour
float angleX = (_destinationX) / _initialXDistance; float angleX = (_destinationX) / _initialXDistance;
float angleY = (_destinationY) / _initialYDistance; float angleY = (_destinationY) / _initialYDistance;
Debug.Log("Angle X: " + angleX);
Debug.Log("Angle Y: " + angleY); Debug.Log("Angle Y: " + angleY);
Debug.Log("Angle X: " + angleX);
if(angleY >= 1 || angleY <= -1) if(angleY >= 1 || angleY <= -1)
{ {
float lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY); //TODO: L'angle fonctionne mieux, mais il y a toujours des problemes avec les angles pret de X
//TODO: Determiner les angles x et y que la fleche doit prendre selon l'angle qu'elle est tiree. //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); float angleS = Mathf.Lerp(lerpStepS, 0, 0);
transform.eulerAngles = new Vector3(0, 0, angleS); transform.eulerAngles = new Vector3(0, 0, angleS);
} }