Character Jump To Z Location?

I have a system where my character checks if the enemy is in the air, if they are my character will jump so it can initiate an air attack on the character.

This works for the most part but if the enemy is higher or lower than the characters jump height my character will obviously overshoot/undershoot the jump towards the enemy.

How can I make it so my character can jump according to the Z location of the enemy?

Any help would be appreciated thanks!