The 43-year-old actor had to shoot a scene from the top of 60-foot long building for the film, reported Daily Star.
In the final film of the trilogy, Galifianakis is featured on the roof top of Caesars Palace trying to save Cooper, who is dangling high above the ground by a bed sheet.
The palace was recreated in a Las Vegas hotel and casino in a sound stage in order to shoot the scene.
Cooper after the shot admitted that he was impressed by the Galifianakis' bravery.
"Zach was a real trooper because he's very scared of heights. And he kept saying, 'Well, what if there's an earthquake?' He said they were just gonna leave me (dangling)," Cooper added.