Quick answer: Unity Mecanim StateMachineBehaviour OnStateEnter never running? The behaviour is attached at the controller or layer level instead of the state, or the Animator isn’t in that state at runtime.
An OnStateEnter override never fires even though the Animator is in that state. The behaviour is attached at the wrong level or the Animator isn’t evaluating.
Per-State Attachment
StateMachineBehaviours attach to states, not to the controller or layers. Select the state in the Animator window → Add Behaviour. Behaviours on a sub-state machine fire on transitions through that machine, not on inner states.
Animator Update Mode
If Animator Update Mode is AnimatePhysics and your scene has no physics ticking that frame, the Animator may skip. Set to Normal unless you need physics sync.
Layer Weight Zero
Behaviours on a layer with weight 0 still fire for state changes but their effects may be invisible because no animation evaluates. Set layer weight > 0 to see results.
Verifying
OnStateEnter fires for every entry into the state — one log line per transition. OnStateExit fires on leaving.
“Attach behaviours to states. Sub-state-machine attach behaves at the parent level.”
Avoid heavy logic in StateMachineBehaviours — they run for every Animator instance and can become a perf cliff in crowds.