Neil Patrick Harris spoke to GQ about playing Barney Stinson in "How I Met Your Mother."
Harris said Barney's evolution was "mostly" due to his real-life "talent crush" on Cobie Smulders.
"I started flirting with her as much as I could on camera," he said.
Neil Patrick Harris said that his real-life adoration for "How I Met Your Mother" costar Cobie Smulders contributed to his character Barney Stinson's storyline in the hit sitcom.
"I think Barney's evolution mostly came about from my falling in love with Cobie Smulders," Harris said while discussing his career in a new video for GQ.
Harris told the publication that he didn't fit into the initial description of the character and he was skeptical of "HIMYM" because of the "terrible" title.
"Who names a show, 'How I Met Your Mother?' There's not even any rhyming to it," he said. "Like, a bunch of basic words put together as a sentence. It's not a title, but I digress."
The series - costarring Josh Radnor, Jason Segel, and Alyson Hannigan - ran for nine seasons between 2005 and 2014. Harris portrayed Barney, a womanizer with a penchant for wearing suits at all times.
Over the course of the show, architect Ted Mosby (Radnor) told two children how he met their mother, through a series of long-winded stories about his life as a single, optimistic guy living in NYC with his friends.
"HIMYM" also featured plenty of celebrity cameos, from Jennifer Lopez and Britney Spears to Harris' real-life husband, David Burtka.
The series premiere established that Smulders' character, a TV journalist named Robin Scherbatsky, wasn't the titular mother, despite her and Ted's flirtations in the episode. Instead, she was referred to as "aunt Robin."
Harris told GQ that he used that to his advantage as the show continued.
"I was like, wait a second. She's so talented and hot and funny and Canadian already," he said of Smulders. "That's four stars. She's just amazing. So I started flirting with her as much as I could on camera and that Barney could do all of that."
"I kind of like had a talent crush on Cobie Smulders," Harris added.
As "HIMYM" progressed, Barney slowly shed his playboy persona and developed romantic feelings for Robin.
"They sort of saw our chemistry change," Harris said. "And then that shifted Barney into being more single-minded and really honoring the notion of changing who he is and changing his ways as much as he was able."
Barney proposed to Robin in season eight and they got married in season nine.
But part one of the series finale revealed that Barney and Robin got divorced after three years of marriage. At the end of the finale, Robin ended up with Ted.
"I meet a lot of straight frat kinda guys at bars that are super stoked that I'm the guy who played Barney Stinson and some of them tell me that they're not gay, but that they would fool around with me," Harris told GQ. "That doesn't happen nearly enough, the follow through, do you know what I'm saying? But I'm flattered by the ida of it, by the notion of it."