You can actually quite a bit with just a few drivers.
I'm not going to explain the entire process, but I'll cover a lot of the more interesting points.
If you haven't already, learn how drivers work (here's a tutorial I made). They're an extremely powerful way to control different object attributes.
For the barrel recoil, I created a driver that makes the barrel follows the position of an empty (the one moving back and forth). The position of each section of the barrel is just controlled by a custom curve (offset for the back section so it follows slower). This is the curve of one section:
There are three bullets at the beginning of the animation hidden in the back of the barrel. I couldn't figure out how to dynamically add them while the animation was playing. There might be a hacky way to do it with a particle system, but I decided that hiding them was the simplest solution.
The first thing to note about the bullets is that they're dropping as they follow the empty. All I did was create a driver that calculates the trajectory of the projectile using the Y position of the empty for the current distance. Because it was long (and hard to type into the
expr bar), I just put it in a Python script:
Then all you have to do in the
expr box is put:
calc_path(x, ang, height, velocity).
Finally, the bullets are set to be animated rigid bodies. That way they can interact with the other rigid bodies in the scene. When I wanted them to simulate and bounce around on the ground, I simply animated the
animated attribute in the rigid body settings:
The result isn't completely elegant, but it certainly does cut down on the amount of animation you have to do.
If you're interested in dissecting the .blend yourself, you can download it.