Can a transition in the Animator automatically call a function?

When a transition from one state to another occurs, I want a specific function in my code to be called. What would be the best way to do that?

Yes, try to use this : State Machine Behaviours