Paper2D AI

I’m making a tank game which I want the enemy AI to move in random directions and when the player is in range, the AI stops and starts shooting and only move its cannon. I’ve already done some Paper2D AI that followed and shot the player.