“I am Gunnery Sergeant Hartman, your senior drill instructor. From now on, you will speak only when spoken to, and the first and last words out of your filthy sewers will be ‘sir.’ Do you maggots understand that?” he begins, launching into a nearly six minutes of rapid-fire dialogue.

The famous scene is a brutal verbal assault, insults flying as fast as machine gun bullets. Many lines from it have become iconic, such as “What is your major malfunction?” It became so celebrated that other shows and movies, including “The Simpsons,” often paid homage to it.

Ermey died Sunday at 74, from pneumonia-related complications. His furious performance in “Full Metal Jacket,” much of which was improvised, earned him a Golden Globe nomination and launched his career, but it almost never occurred. He wasn’t even an actor at the time.

Serendipitous events beginning in his childhood led to the role.

As a teenager, the Kansas native was arrested twice for criminal mischief. The court gave him a choice: prison or military, according to Deadline. He chose the latter and joined the Marine Corps. He served for 11 years, spending 14 months in Vietnam and completing two tours in Okinawa, Japan. Eventually he became a drill sergeant, which is one reason he so excelled as Hartman.

After retiring from the military, he took some acting classes and decided on a new career path.

He once told an interviewer that he devised a plan to break into Hollywood: Use his knowledge from his military service to become a technical director on certain films. Then, once in the crew, show filmmakers that he should be starring in their movies.

The plan worked three times in a row, scoring him the first three roles of his career: a sergeant in Sidney J. Furie’s “The Boys in Company C,” a helicopter pilot in Francis Ford Coppola’s “Apocalypse Now” and the role of Hartman.

Ermey persuaded Kubrick to cast him by making a homemade audition tape that showed him screaming insults with a stone face as tennis balls and oranges flew at his head, according to the Guardian.

Once he landed the role, he rehearsed in the same manner. Kubrick’s assistant Leon Vitali would sit across from Ermey in a 50-foot-long room and hurl tennis balls at the actor practicing his lines.

”I had to catch the ball and throw it back to Leon as fast as possible and say the lines as fast as possible,” Ermey told the New York Times in 1987. “If I were to slur a word, drop a word or slow down, I had to start over. I had to do it 20 times without a mistake. Leon was my drill instructor.”

For the most part, those lines weren’t written. Ermey improvised about half of his dialogue, drawing on memories from the service.

“In the course of hiring the Marine recruits, we interviewed hundreds of guys,” Kubrick told Rolling Stone. “We lined them all up and did an improvisation of the first meeting with the drill instructor. They didn’t know what he was going to say, and we could see how they reacted. Lee came up with, I don’t know, 150 pages of insults.”

Inventing those insults wasn’t particularly difficult for Ermey — he was just being a drill sergeant, this time on camera.

“My main objective was basically to just play the drill instructor the way the drill instructor was and let the chips fall where they may,” Ermey said in a History Channel interview. “You can ask any drill instructor who was down there in 1965 or 1966, that’s exactly how the drill instructor’s demeanor was. There were no punches pulled.”

Those insults effectively launched Ermey’s varied career. He appeared in a wide range of television shows and movies, including “Se7en,” “The Simpsons” and the “Toy Story” movies (in which, naturally, he voices a plastic green army man named Sarge).

But even though he was known for portraying loud, angry drill sergeants, his longtime manager Bill Rogin said the actor was nothing like his characters.

“Gunnery Sergeant Hartman of Full Metal Jacket fame was a hard and principled man,” Rogin said in a statement. “The real R. Lee Ermey was a family man, and a kind and gentle soul. He was generous to everyone around him. And, he especially cared deeply for others in need.”

Travis M. Andrews is a pop culture writer for The Washington Post. He joined The Post in 2016 as a reporter for Morning Mix. Previously, he was a travel and culture editor for Southern Living magazine and a pop culture and tech contributor for Mashable.