NPC-Barrier Interaction

Hey! So I am thinking through a mechanic where the player character is behind a fence for example. The fence is just one long unit for this question and assume there is a wall on either side of the fence. I want AI to track if there is a path to the player, and if not, then attack the fence. Fence health = 0, destroy fence, etc and all that. I am just unsure how to lay out the logic so that the AI will attack the player and first the fence. Im new to the engine so extra information and clear answers/examples would be great! Thank you!