Parasitic wasps deposits their eggs through the skin of a caterpillar. When the eggs hatch, they eat their way out through the skin of the caterpillar. The caterpillar not only survives the trauma, it also protects the parasite by acting as a bodyguard, totally mind-controlled by the parasite.
The cocoons are the final transformation before the adult wasps hatch. Once their host served it's purpose, the unfortunate caterpillar finally succumbs to starvation...So do you want to tell me about the bad day you are having...?