Vehicle with movable component: How to approach it?

Ok, this doesn’t sound foreign, I have seen and used this in other programs. But I don’t see how I would do an actual animation. A properly, fluently backflipping modular Pawn? Then I would have to code the animation, and that sounds like a terribly ugly, inefficient and insufficient solution. The gun on the car might work like this, but that might have been too simple of an example.