The director M. Night Shyamalan is out on Friday with a new movie, “The Visit,” a film about two kids who have a lovely time hanging out with their grandparents.

In classic Shyamalan fashion, the movie may provide a pretty huge shock: It’s earning a good score on Rotten Tomatoes! Not a great score, but leagues ahead of what we’d expect based on the director’s recent work. How did one of the most promising directors of the early 2000s get to the point where we’re expecting schlock?

Incorporating data from Rotten Tomatoes and OpusData, let’s review the story of how Shyamalan tanked his directorial reputation, and the small-budget horror comedy that might redeem it.

The Golden Age of M. Night Shyamalan

“The Sixth Sense” is a really good movie. The film is about a troubled child learning how to cope with the help of a psychologist friend (Bruce Willis) who’s learning how to move on with his life. “The Sixth Sense” made an alarming amount of money — it was the second-highest grossing film of 1999 — and generally pulled the carpet out from under the feet of audiences, earning an 85 percent certified fresh Rotten Tomatoes rating from critics and an 89 percent favorable score from fans.

Shyamalan next directed “Unbreakable,” a movie about a superhero and his mentor also starring Willis, this time alongside Samuel L. Jackson. Shyamalan’s first post-“Sixth Sense” film was also very well received — a Rotten Tomatoes score of 68 percent — though less of a box office smash. Two years later, Shyamalan hit another one out of the park with the 74 percent-fresh “Signs,” a surprisingly deep film about aliens with enough thematic depth to fuel one of my favorite movie theories.

All are solid Shyamalan! They’re the kind of movies that if you’re bored and they’re running on TBS you’ll watch to the end. They’ve each got a legitimate emotional turn and take a crack at interesting themes, all while using the patented Shyamalan twist.

But this schtick got old really fast.

The Breaking Point

In 2004, “The Village” constituted a bit of a breaking point for Shyamalan. The film featured Bryce Dallas Howard, Joaquin Phoenix and Academy-Award-winner/future-“Dragon Blade”-star Adrien Brody as people mixed up in a deranged Colonial Williamsburg situation . Financially and critically, it was the worst of Shyamalan’s wide-release movies at the time. [Editor’s note: I disagree — the “The Village” was OK.]

The twist in “The Village” was nothing particularly new, and while the earlier three films had a solid emotional center (broken child bonds with surrogate father, broken man bonds with broken man, broken father connects with daughter), “The Village” just felt trite.

Once a director builds a brand, it’s difficult to bust out of it. If you see a Michael Bay movie, you’re going to get explosions. If you see a J.J. Abrams movie, you’re going to see lens flare. If you see a Steven Spielberg movie, you’re going to see a child of divorce learn self-reliance while being hurt by the world. And if you see a M. Night Shyamalan movie, you’re going to see a plot twist that attempts to shift the perspective of the viewer. By the time “The Village” came out, audiences had caught on. And while some directorial predilections are transferable and repeatable, Shyamalan’s became stale. He kind of became the Gallagher of film.

“The Village” garnered only 43 percent at Rotten Tomatoes, and while domestically it did about double its budget, the film was nonetheless a sign of things to come.

The Twizzlers

As exciting as Shyamalan’s 1999-2002 period was, that’s how disappointing his run since 2006 has been.

Shyamalan followed up “The Village” with “Lady in the Water,” a critical and box office flop about a man who finds a lady in a pool. “Lady in the Water” was innovative in one regard, at least, proving that it was possible for Paul Giamatti to be in a bad movie. This is a film that is literal self-insertion fan fiction by Shyamalan. Ever interested in hearing alternative viewpoints, I contacted a close friend of mine from college — the only person I ever met who loved this movie — to answer for its crimes. Then, this happened:

He later added “This movie is actually entertaining because he tries so hard to throw in a twist that it feels like a high school play,” a sentence I deeply wish I wrote.

Moving on, Shyamalan would go on to make “The Happening.” The twist in this movie is that Mark Wahlberg was cast to play a person qualified to teach children about science. Indeed, several years later at a press conference promoting “The Fighter,” Wahlberg would say:

We had actually had the luxury of having lunch before to talk about another movie, and it was a really bad movie that I did. She dodged the bullet. And then I was still able to…I don’t want to tell you what movie…all right, The Happening. F— it. It is what it is. F—ing trees, man. The plants. F— it. You can’t blame me for not wanting to try to play a science teacher. At least I wasn’t playing a cop or a crook.

That feeling you are having right now? That’s your respect for Mark Wahlberg, hamburger entrepreneur, swelling.

While 2010’s “The Last Airbender” would make comparatively more money than the other shit-tier Shyamalan films, it’s by far the most poorly-reviewed of any of the movies he’s directed. It is legitimately difficult to pull off a 6 percent Rotten Tomatoes score. The wide deviation from the beloved source material, the whitewashed casting for characters who were canonically Asian and — of course — incoherent plot twists combined to make a thoroughly unwatchable film. And while it’s always important to be skeptical of a crowd-sourced encyclopedia, “The Last Airbender” somehow made it through the editorial gauntlet to earn a spot onto my third-favorite Wikipedia list, “List of Films Considered The Worst.”

By the time “After Earth” (2013) came out— a film that takes its twist verbatim from “Planet of the Apes” — studios were actively avoiding mentioning the name “M. Night Shyamalan” in trailers. “After Earth” proved to be a financial and critical failure, pulling $60 million domestically and languishing with an 11 percent Rotten Tomatoes rating.

Having hit that particular rock bottom, there’s really nowhere to go but up. Maybe the director will finally pull of one of his famous twists.

The Twist?

Those final two films — a CGI-fueled fantasy film based on a beloved cartoon and a CGI-fueled Will Smith family vanity project — feel a little out of step with the director’s previous oeuvre. Given how technically coherent and visually compelling the films are, it’s not really fair to imply that Shyamalan was out of his depth here, but it does make this forthcoming return to horror all that more intriguing, even if it does seem like he bit the “handheld shaky cam” cinematography bait.

“The Visit” was made for a dirt-cheap $5 million, so it’s basically impossible for it to lose money unless something terrible happens. The movie is sporting a frankly shocking preliminary Rotten Tomatoes rating of 64 percent fresh (as of Friday morning).

While the trailer does save it for the end, the promotional materials are referring to him by name again, making a point to mention it’s “From the writer and director of The Sixth Sense, Unbreakable, The Village and Signs.”

Take that however you will, but here’s hoping his time in the wilderness made M. Night Shyamalan a better director of the kind of movie that made him big in the first place: tense, tightly-written thrillers with a strong emotional core. Sure, there’s probably going to be gauzy convolutions of plot, but emotional heart can cover for that. Anyone who enjoyed his early work has to be rooting for a comeback.