Ai animation

Im currently using the pawnsensing component and have the" ai move to" inside the ai blueprint I’m trying to figure out how to make the ai play the animation only when it senses me and make the animation stop when I’m out of it’s vision.

Pawn sensing component has method (not available from blueprint):

/** 
* Chance of seeing other pawn decreases with increasing distance or angle in peripheral vision
* @param bMaySkipChecks if true allows checks to be sometimes skipped if target is far away (used by periodic automatic visibility checks)
* @return true if the specified pawn Other is potentially visible (within peripheral vision, etc.) - still need to do LineOfSightTo() check to see if actually visible.  
*/
virtual bool CouldSeePawn(const APawn* Other, bool bMaySkipChecks = false) const;

If you interrogate it every frame, you can find out whether the enemy is visible at the moment.