“Robin Williams: Come Inside My Mind” fittingly starts out by showcasing how the comedic master’s mind ricocheted at a dizzying velocity, bouncing around from character to character.

The new documentary, which premiered at Sundance this year and may now be seen on HBO and HBO Go, attempts to solve the mystery of that mind and what drove Williams throughout the years.

Filmmaker Marina Zenovich, who also made films about Roman Polanski and Richard Pryor, interviews several of his high-profile friends, such as Billy Crystal, David Letterman and Whoopi Goldberg, as well as his first wife, Valerie Velardi, and one of his children, Zak Williams.

Much of the film’s two hours are narrated by audio clips from interviews with Williams.

The documentary doesn’t dwell for very long on the exact circumstances around Williams’s 2014 death. According to an essay from his wife, Susan Schneider Williams (who is not in the film), he had Lewy body disease and died from suicide “at the end of an intense, confusing, and relatively swift persecution at the hand of this disease’s symptoms and pathology.”

Instead, several people in the documentary note that the “sparkle had gone out of his eye” during the time Williams worked on his 2013 sitcom, “The Crazy Ones.” Crystal remembers seeing Williams for the last time when he revealed he had been diagnosed with Parkinson’s disease. “When he told me, I never heard Robin be afraid except for that moment,” Crystal says.

Here’s what else we learned:

He was a classically trained actor, and it came in handy

Williams first realized the power of comedy when his father, a man who did not easily laugh, “lost it” watching Jonathan Winters on “The Tonight Show.”

Williams got into improvisational theater because it was the only course offered at his all-men’s college that also had female students. He later enrolled at Juilliard in New York, and dove into comedy back in California after he couldn’t get serious acting work.

In his first paid comedy gig, the microphone died. So he just went right into the audience, doing crowd work and improvising bits. Thanks to his theater training, he could project his voice with no problem.

Many years later, Williams would display his acting range with dramatic roles in which he slowed down and exposed his vulnerability.

David Letterman was initially wary

Williams first met David Letterman in the Los Angeles comedy scene of the 1970s, and the two would grow closer as they got older.

“When we first saw Robin on stage, we were skeptical, and we made it kind of a project to keep our eye on him,” Letterman recalls. “In my head, my first sight of him was that he could fly because of the energy. It was like observing an experiment.”

He got his big break thanks to “Star Wars” and an 8-year-old

“Happy Days” creator Garry Marshall noticed his 8-year-old son Scott was no longer watching his TV show. “There’s no spaceman on it,” Scott Marshall recalls in the film.

So papa Marshall asked the writers to work in a spaceman character. Scott’s aunt, Ronnie, was in charge of casting and suggested a comedic street performer for the role. And boom: Williams came to “Happy Days” as Mork, an episode that earned a standing ovation from the studio audience.

ABC spliced together a pilot by combining the Mork episode with another failed TV show, and “Mork and Mindy” was born.

He’s the reason behind the four-camera sitcom

Before Williams starred in “Mork and Mindy,” multicamera sitcoms relied on three cameras. But then came this kinetic actor who was running around the set and improvising, and the cameramen would fail to capture the antics that came when he wasn’t hitting his predetermined marks.

So Gary Marshall came up with a solution: Add a fourth, almost hand-held camera tasked with following Williams. Since then, four-cameras became the standard for sitcoms.

John Belushi’s death had a huge impact on him

Williams was one of three people with the famously hard-partying Belushi the night he died following an overdose of cocaine and heroin.

According to the documentary, Williams learned that Belushi died the following day on the set of “Mork and Mindy.”

His sudden death led to Williams, who had been heavily drinking and doing drugs as well, sobering up.

“Here’s this guy who was a beast, who could doing anything, and he’s gone,” Williams said.

He would leave hilarious voice mails for Billy Crystal

Perhaps the most intimate aspects of the documentary are the stories from Williams’ close friends and family members. His friendship with Crystal began in New York City after the fellow comedic actor got Williams’ baby to stop crying.

“Everybody wanted something from him,” Crystal says. “I had no agenda. I just liked him.” Over the years, Williams would call Crystal in character, like the time he rang up as Ronald Reagan while Crystal was watching the former president’s funeral. The film includes old voice messages from Williams performing for an audience of one: his friend.

Comedy was a refuge, and an addiction

One through-line for the documentary is why comedy became so integral for how Williams functioned.

After “Mork and Mindy” got canceled, Williams returned to stand-up comedy as a refuge and as a survival mechanism. Even on serious movie sets, such as “One Hour Photo,” Williams had to crack up co-stars.

“The urge to be funny and make people laugh was so innate in him and almost like breathing for him, that if he didn’t get that out of his system, it would’ve infected his performance in a bad way,” says director Mark Romanek. “So I would just let him go as long as it was reasonable for time in the day, to just get it out of his system.”

Crystal adds, “It’s a very powerful thing for a lot of comedians. That laugh is a drug. That acceptance, that thrill, is really hard to replace with anything else.”