Flèches droites peuvent changer d'angle #7
@ -76,7 +76,7 @@ public class Projectile : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
float x = _speedTime;
|
float x = _speedTime;
|
||||||
float y = (_angle*-Mathf.Pow(x, 2) + _destinationX * x);
|
float y = x >= 0 ? (_angle*-Mathf.Pow(x, 2) + _destinationX * x) : - (_angle * -Mathf.Pow(x, 2) + _destinationX * x);
|
||||||
|
|
||||||
transform.position = new Vector2(_initialX + x*_angle, _initialY + y);
|
transform.position = new Vector2(_initialX + x*_angle, _initialY + y);
|
||||||
|
|
||||||
@ -105,18 +105,22 @@ public class Projectile : MonoBehaviour
|
|||||||
|
|
||||||
//Debug.Log("Angle X: " + angleX);
|
//Debug.Log("Angle X: " + angleX);
|
||||||
|
|
||||||
if(diffY >= 0.1 || diffY <= -0.1)
|
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
|
//TODO: L'angle fonctionne mieux, mais il y a toujours des problemes avec les angles pret de X
|
||||||
//ou ils sont beaucoup trop verticaux.
|
//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
|
//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.
|
//lorsque X est negatif.
|
||||||
|
//TODO: Recalculer la vitesse pour qu'elle fonctionne lorsque le projectile est tire en arriere.
|
||||||
float lerpStepS;
|
float lerpStepS;
|
||||||
if(angleX > 0.235) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY);
|
if (angleX > 0.23) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY);
|
||||||
|
|
||||||
else if (angleX >= 0) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleY / angleX);
|
else if (angleX >= 0) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleY / angleX);
|
||||||
|
|
||||||
else 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);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user