There are multiple reasons why its not getting called,
- The Destination in “AI Move To” is 0,0,0 which will make AI move to that location, now your function may get called but montage wont play bcuz you are comparing the distance with the controlled pawn.
- You calling this on event tick, and event tick gets called every frame which might bug this out.
- The controlled pawn’s location that you are subtracting with the actor’s location there’s a chance both are same values.
What you can do now is get the location of actual target by doing a trace or overlap check with a sphere, you can set the sphere radius or trace length same as ur attack range and whenever the condition is true i.e player overlapped with collision sphere or the trace detected player you can play your montage.
For your case Behaviour Trees would be best and simple