2D Platform AI Jump

Hey guys,
I’m making a 2.5D AI that moves by using waypoints. I already have this movement towards the waypoints. But what i want now is too make the AI jump onto a higher platform. I have been trying some stuff but every time it doesn’t work out as i want it too. My code that moves the Ai at the moment is this :

private void MoveTowardsWayPoint()
    Vector3 target = wayPointList[currentWayPoint].transform.position;
    moveDirection = target - transform.position;

    float disY = target.y - transform.position.y;
    if (moveDirection.magnitude< 0.2f)
        currentWayPoint = 1;
    if (Input.GetKeyDown(KeyCode.A) && controller.isGrounded)
        moveDirection.y = 12;

    moveDirection.y -= 30 * Time.deltaTime;
    controller.Move(moveDirection.normalized * 5 * Time.fixedDeltaTime);

But now everytime it Jumps it makes a mini jump and it still runs up to the higher platform’s. And i already tried to set the moveDirection.x = target.x - transform.position.x ; but that doesn’t help either cause then the movement gets fcked up. Anymore a idea how i could do this the best and cleanest.


I didn’t understand why your AI needs input (pressing A) to jump… Isn’t an ai supposed to do stuff by himself?

Also, try this:

if (target.y > transform.position.y) { //if the target is higher than you
**Jump command here**