Headbob when being hit

I want my camera to tilt a bit when the player gets hit by a zombie.
This is to better visualize that you got hit by a zombie.
So I attached a animator to my camera.
And I made a animation where the camera rotates a bit and comes back.
But I can only move my camera left to right and not up to bottom when a animator is attached.
How can I still move my camera freely but rotate the camera along the z-axis when I got hit?

I found the answer!
You have to make an empty gameobject where you attach the animator to.
Then make this the parent of the camera. This way you can animate the empty and the camera can move freely.