How do I make the enemy of my videogame to move like this?

The enemies must follow the player direction and atack him with this V movement when they are very close to him just like the Bunby Helis from Megaman NES:


Probably something like,
Let’s call them heli
At beginning, take their original y coordinate and assign it into an object number variable “originheight”.
Set a certain object boolean variable, say “vattack” to false.
If vattack is false,
Give them force to move horizontally towards the players x coordinate.
Check distance of player x coordinate and heli x coordinate if it is within a certain distance.
If close enough, switch “vattack” to true.
Get position of player(x and y this time), give heli force to move towards player’s position.
When position is reached, resume original force to move horizontally.
Check y coordinate against the variable originheight. If it is not equal, then give them force to move that way.
When heli y coordinate is close enough to originheight value, remove the movement force.
Set “vattack” to false and give new horizontal movement towards the player.
Rinse and repeat.

Maybe the return to “originheight” might need a boolean there as well, idk. But yeah, theoretically that’s how I imagine it would go.