Flèches droites peuvent changer d'angle #7
@ -14,4 +14,4 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
_upgradeUnitCard: {fileID: 11400000, guid: 4728bef0a18b70945bedf5b1190c491e, type: 2}
|
||||
_upgradePrefab: {fileID: 1436362432952518814, guid: 8d56b160dedb7f84d830d749372fe8e8, type: 3}
|
||||
_upgradeCardArt: {fileID: 21300000, guid: bc54d5d5ac69f334daf7b36882bd5199, type: 3}
|
||||
_upgradeCardArt: {fileID: 21300000, guid: bf13763ff43b8114b8bdca864dfdf62f, type: 3}
|
||||
|
||||
@ -32,6 +32,7 @@ public class Projectile : MonoBehaviour
|
||||
private float _initialY;
|
||||
private float _destinationX;
|
||||
private float _destinationY;
|
||||
private float _enemyPosY = 0f;
|
||||
private float _speedTime = 0f;
|
||||
|
||||
private float _initialXDistance;
|
||||
@ -94,22 +95,28 @@ public class Projectile : MonoBehaviour
|
||||
private void DetStraigthArrowAngle()
|
||||
{
|
||||
|
||||
if(_target != null) _enemyPosY = _target.Position.y;
|
||||
|
||||
float angleX = (_destinationX) / _initialXDistance;
|
||||
float angleY = (_destinationY) / _initialYDistance;
|
||||
|
||||
//Obtenir difference entre la position Y du chateau et de l'enemie.
|
||||
float diffY = transform.position.y - _enemyPosY;
|
||||
|
||||
//Debug.Log("Angle X: " + angleX);
|
||||
|
||||
Debug.Log("Angle Y: " + angleY);
|
||||
Debug.Log("Angle X: " + angleX);
|
||||
|
||||
if(angleY >= 1 || angleY <= -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
|
||||
//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
|
||||
//lorsque X est negatif.
|
||||
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);
|
||||
if(angleX > 0.235) lerpStepS = Mathf.Rad2Deg * Mathf.Atan(angleX / angleY);
|
||||
|
||||
else if (angleX >= 0) 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