Hi Hazel,
I possibly need some more coffee this morning but i am trying to understand where the bug is in your project.
It sounds like you are saying that the animation plays when you play it via the animator and it plays in the scene view but when in play mode its not working?
Can you provide some screenshots of the code, The link up in the inspector and if possible a short video of what you are seeing.
I know you are pretty experienced in using unity so i am pretty sure your code will be correct but maybe somewhere its not linked up correctly as i have done that myself in the past (Even forgot to add the script to a gameobject before!)
If all else fails i can get a copy of your project and try to have a look directly as a second set of eyes can often help.