How to perform an action for any move?

I need to modify the variable every time the character makes a move, and it can move under the control of the player controller, and under the control of the AI controller.

The movement will be carried out by MoveTo functions for AI, as well as the function AddMovementInput.

How can I do that? Which function to redefine or to which event to become attached?