Saving gameplay to animation

I'm wondering if this is possible. I have a racing game that I'm working on and wanted to include a sort of instant replay or ghosting system, like the ghosting in mirror's edge, or the flashbacks in dirt 2. So is there a way to record gameplay to animation files?

I know this is possible in other game engines, for example the blender game engine.

Virtually anything is possible with Unity, you just need to know how to code it yourself, there's no neat little function or something to help you do it.

I would just save some crucial information every frame (or every other frame), and then compile it into some data format that you can export to a file, which you would then read back, and use the data to create a ghost. You would probably end up saving the position, rotation, and any other important variables like how much the wheels are turned, how much damage the car has, and that sort of thing. Again, this is all totally doable, you just need to code it in yourself.