Often sleep is exactly what we need to recover from overwork or writer's block or the inability to get anything done. And maybe if you're really lucky, the answer to what you're looking for will come while you sleep! Don't count on it -those moments are rare, but they do happen. In some cases, inspiration comes in a dream when you weren't even looking for one.
Does an emotionless cyborg killing machine that looks like Arnold Schwarzenegger seem like a nightmare to you? It was a nightmare for James Cameron. He was fighting a 102-degree fever when a vision of a robot dragging itself along the floor with a knife came to him in his sleep. Apparently Cameron brainstorms best in a dream state: it’s how he thought of Avatar as well.
His is one of eleven such stories at mental_floss. Link