Updated Straight Projectile Workings
Updated the function that changes the angle of the straigth projectile to work better the closer the enemy is to the shooter. There is some more fixes to be done, as those close angles are too vertical.
This commit is contained in:
parent
ad66f2e22c
commit
d454865a24
@ -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);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user