I want you to modify the simulate projectile function:

*Start the parabolic movement at the initial transform. position
*The maximum height is reached at the middle of the trajectory
*End the movement in currentTarget
*the longer the distance the arrow goes up, the shorter the distance the arrow goes down, the minimum height is a straight line with the target

using System.Collections;
using Game.Systems;
using UnityEngine.UIElements;

namespace Game.ImprovedAI
{
    using System.Collections;
    using UnityEngine;

    public class Arrow : MonoBehaviour
    {
        public float speed = 10f; // Velocidad constante de la flecha
        public float maxHeightFactor = 0.25f; // Factor de la distancia que afecta la altura máxima
        public float chaseDistance;
        public float damageRange;
        public GameObject target; // Posición del objetivo

        private Vector3 startPoint;
        private float travelTime;
        private UnitHealth unitHealth;
        private float damage;


        public void Init(GameObject target, UnitHealth unitHealth, float damage)
        {
            this.target = target;
            this.unitHealth = unitHealth;
            this.damage = damage;
            startPoint = transform.position;
            InitiateFlight();
        }

        void InitiateFlight()
        {
            // Calcular la altura máxima basada en la distancia al objetivo
            float distance = Vector3.Distance(startPoint, target.transform.position);
            float maxHeight = distance * maxHeightFactor;

            // Calcular el tiempo de vuelo basado en la velocidad constante
            travelTime = distance / speed;

            // Iniciar la simulación de la trayectoria
            StartCoroutine(SimulateProjectile(maxHeight));
        }

        IEnumerator SimulateProjectile(float maxHeight)
        {
            float elapsed_time = 0;

            Vector3 currentTarget = target.transform.position;
            
            while (Vector3.Distance(transform.position, currentTarget) > damageRange)
            {
                elapsed_time += Time.deltaTime;
                float progress = elapsed_time / travelTime;

                // Interpolar la posición horizontal
                Vector3 horizontalPosition = Vector3.Lerp(startPoint, currentTarget, progress);
                // Calcular la posición vertical con una función parabólica basada en el progreso
                float height = (-4 * maxHeight * progress * (progress - 1));

                // Calcular la próxima posición
                Vector3 nextPosition = new Vector3(horizontalPosition.x, height, horizontalPosition.z);

                // Rotar la flecha hacia la dirección de movimiento
                RotateTowardsMovement(nextPosition);

                // Mover la flecha
                transform.position = nextPosition;
                
                if(Vector3.Distance(transform.position, target.transform.position) < chaseDistance)
                {
                    currentTarget = gameObject.transform.position;
                }
                
                if(Vector3.Distance(transform.position, target.transform.position) < damageRange)
                {
                    if (unitHealth != null)
                    {
                        unitHealth.TakeDamage(damage);
                    }
                }

                
                yield return null;
            }
            
            OnReachTarget();
        }

        void RotateTowardsMovement(Vector3 nextPosition)
        {
            Vector3 directionOfMovement = nextPosition - transform.position;
            if (directionOfMovement != Vector3.zero)
            {
                Quaternion rotation = Quaternion.LookRotation(directionOfMovement.normalized);
                transform.rotation = rotation;
            }
        }

        void OnReachTarget()
        {
            // Aquí se maneja el impacto o llegada al objetivo
            Destroy(gameObject); // Por ejemplo, destruir la flecha cuando impacta el objetivo
        }
    }
}