DETROIT – What did the stars of “The Hangover Part III” do with their free time on the set? Just your average sarcasm-driven male bonding, according to Zach Galifianakis.

“The downtime is usually just making fun of each other, relentlessly. That’s what keeps any attempt at an ego from coming out, because it’s not allowed,” says the comedian, who plays adult problem child Alan in the wildly successful comedy series.

Speaking from Las Vegas, the sacred city of “Hangover” high jinks, Galifianakis says he usually bears the brunt of such mockery from his co-stars. “As a matter of fact, we just had lunch and everybody jumped on my case about something,” he says. That something being a lie about meeting Mick Jagger after a Rolling Stones concert and finding out he was a big “Hangover” fan.

“They got so excited and I had to tell them that I was kidding. And they were like, ‘Why would you say that?’ ” he recalls with a laugh.

Ego may not be a part of “The Hangover” films, but wild success is. The first movie in 2009 earned $467 million worldwide, while “The Hangover Part II” raked in roughly $587 million, according to Box Office Mojo. The third film has already earned $88 million in only two weeks. And the mayhem wreaked by three guys who keep waking up with no memory of what’s happened has made stars out of Bradley Cooper, Ed Helms and Galifianakis.

In this third installment, Alan undergoes a sort of psychic meltdown after his father (Jeffrey Tambor) dies, prompting his old pals Phil (Cooper) and Stu (Helms) to coax him into seeking treatment at an inpatient facility. Their journey goes awry when they run into a very scary individual (John Goodman) who’s looking for the millions that “Hangover” regular Mr. Chow (Ken Jeong) has stolen from him.

Director Todd Phillips told Galifianakis before the screenplay was written that the final chapter would be about Alan’s intervention and his father’s death. The bearded comedian says the storyline brings some unexpected, softer moments for his character and has a few emotional arcs that comedies tend to avoid.

“It’s fun to play and I’m glad that Todd decided to do it,” he says.

He’s also pleased at the addition to the cast of Melissa McCarthy (“Bridesmaids”), who plays a love interest for Alan. “I’m glad that finally we have some female energy in this movie. I think it helps,” he notes.

But don’t confuse this “Hangover” with a tender love story. In keeping with the brand, the atmosphere is raucously wild and action-packed, as indicated by the scenes in the commercials where Alan drives a giraffe in an open trailer down a freeway.

“There was not a giraffe in my back trailer, they just CGI’ed the entire thing,” he explains. Then he weighs in on how close visual effects are getting to perfectly simulating people. “I got in lucky as an actor, because in a few years, they’re not going to need us.”

Since 2009, Galifianakis has had a crowded film schedule and done several hugely popular guest-hosting stints on “Saturday Night Live.” It took some time for him to get used to all of the fame, particularly since people are apt to confuse him with the bizarre, uninhibited Alan.

Even Matt Lauer seemed to have a hard time keeping the two straight during a recent “Today” interview when he asked Galifianakis whether he’d ever been the subject of an intervention and teased him about going off his meds, which Alan does in the script.

Galifianakis says fans often expect him to be Alan-like. “They have giant smiles on their faces sometimes. I feel like they’re disappointed because I’m ultimately kind of a shy, quieter person in real life. People just get excited. Let’s put it this way, if I see a pack of teenagers walking towards me, I will definitely cross the street, because there are expectations, you know?”