Every writer knows the meaning of the word "unmotivated." Some days, it's just an uphill slog to find the energy to even approach the keyboard, much less get actual words on a page.
But there’s another sense of the word "unmotivated" that’s more specific to plot lines. When a story or character suddenly manifests an important element that wasn’t previously set up — when some aspect of the plot that could not have been foreseen by the audience suddenly shows up out of thin air to save the day — this unmotivated, unestablished point is called a Deus ex Machina, a Latin phrase that means “god from the machine."
In classical narratives, the pantheon of Greco-Roman gods would frequently play a role in the proceedings, intervening (often climactically) in the lives of the protagonists to twist the story in a direction that better suited them.
When staging these stories for the theater, the actors playing the gods would appear for their final-act, plot-twist meddling thanks to a some mechanical device like a trap door or dangling from a crane (fun!). Hence, "god from the machine."
Sometimes the audience would be in on the fact that the gods are monitoring events and sometimes not, but to the characters in the story, the gods' sudden favoritism was a magical surprise. Creating the sense that a "deus ex machina" moment comes out of left field.
Read More: Final Draft Digs Into Plot Devices: What is Chekhov's Gun?
Fiction and cinema are replete with examples of the deus ex machina at work, so much so that it’s become a common trope. The most cliched version of the trope as it applies to films and TV: the characters in a Western, under siege by antagonistic forces, are suddenly rescued by the cavalry — the existence of which was never previously mentioned, depicted or even hinted at. Blowing a bugle, waving flags, mounted soldiers literally and figuratively show up out of nowhere, unmotivated by previous events. Their appearance couldn’t have been foreseen by the audience.
In general, this sort of usage has led to the deus ex machina being seen as a negative, a big-time writer's no-no. It's now regarded as a lazy plot device that writers use to get themselves out of jams when they haven't properly bothered to set it up earlier OR they can't figure out how to solve a story problem so they just throw some magical zhuzzing at it.
Audiences tend to react to a deus ex machina with annoyance: they've invested in this story and want that pleasurable sense of having solved this narrative puzzle in the end — an out-of-nowhere solution feels like a betrayal. They've been forced to work at playing a game they never had any chance of winning.
What a writer is usually going for when they drop a deux ex machina moment into a script is a twist that's a delightful surprise. The difference between that sort of satisfying "Aha! Moment" that makes total sense in retrospect, and the back-stab that is a deux ex machina, can be summed up in one word: Breadcrumbing.
When a writer sets up a revelation or twist in their story with hints or clues that occur before the big reveal, it's like the fairy tale notion from Hansel & Gretel of "leaving a trail of breadcrumbs," and has become known as "breadcrumbing."
Breadcrumbs make a galaxy of difference to the audience when they realize "I didn't see that coming — BUT I COULD HAVE!" Because whatever this startling plot twist was, it was actually set up in previous scenes and sequences. It makes sense, it may have been a shock, but it's logically sound according to what has been shown previously (and hopefully, sticks to whatever the rules are of the narrative world the writer has created).
Some of the biggest twists in movie history are actually well hinted at earlier in the narrative. A bonus when this is the case: viewers often want to go back and rewatch these stories now that they know, to track how the narrative set it all up. Doubling your ticket sales. BOO-YAH! (Yeah, I know nobody says that anymore.)
Read More: What is a Spec Script and Why You Should Have One
SPOILER ALERT. Oh yeah, I'm about to go a-spoiling. If you somehow plan to see these and still haven't, turn back. You've been warned.
Audiences were left gasping in the aisles by "Oh, no they didn't!" revelations like these:
Come to think of it, Se7en, another Brad Pitt hit, deployed similar breadcrumbing and a big twist. Pro-tip: if you're writing something for Mr. Pitt, he appears to enjoy breadcrumbs.
Just remember when you're contemplating that sharp turn or shocking moment of truth in your script: audiences love them, if you've earned them. It's a fine line between the collective, eye-rolling groan of a deus ex machina, and the deeply satisfying HECK YEAH! of a sturdily pre-constructed plot twist. And that line is made of breadcrumbs.
Enjoy the process!