THE cast of the upcoming Barbie movie were inspired by a Scottish man playing the bagpipes and quoting Braveheart, the film’s director has said.

Greta Gerwig told GQ that Ryan Gosling, who plays Ken in the comedy film based on the hit dolls, had arranged for the cast to hear the Scots music.

She said that, before the movie began shooting, the people playing the various Barbies were having a sleepover, with the Kens also invited to drop in.

Gosling, unable to make it, sent a Scottish bagpiper in his place.

“This man, this Scottish man in a full kilt, showed up and played the bagpipes,” Gerwig said. “Then he read a speech from Braveheart. And then he left.”

READ MORE: Scots stars feature in posters for upcoming Barbie movie

The speech was said to be the part where Mel Gibson’s William Wallace tells his armies that the English may take their lives, but they will never take their freedom.

“Sometimes, you just need to hear it,” Gerwig said.

She added that Gosling “always can sense very quickly what would be the most delightfully funny thing to do next, and then he does it”.

Gosling also defended his casting in the highly anticipated Barbie movie, saying: “If people don’t want to play with my Ken, there are many other Kens to play with.”

The Hollywood actor, 42, stars alongside Margot Robbie in the live-action film based on the famous Mattel doll.

After he was cast in the role, fans on social media suggested Gosling (below) was too old to play Barbie’s boyfriend.

The National: Ryan Gosling (Gregory Harris/PA)

Responding to the criticism, he told GQ: “It is funny … this kind of clutching-your-pearls idea of, like, #notmyken.

“Like you ever thought about Ken before this? But suddenly, it’s like, ‘No, we’ve cared about Ken this whole time’.

“No, you didn’t. You never did. You never cared. Barbie never f***** with Ken. That’s the point.

“If you ever really cared about Ken, you would know that nobody cared about Ken. So your hypocrisy is exposed. This is why his story must be told.”

He also said he found connections between his childhood self and the character, saying: “There’s something about this Ken that really, I think, relates to that version of myself.

“Just, like, the guy that was putting on Hammer pants and dancing at the mall and smelling like Drakkar Noir and Aqua Net-ing bangs. I owe that kid a lot.

“I feel like I was very quick to distance myself from him when I started making more serious films. But the reality is that, like, he’s the reason I have everything I have.”

The Oscar-nominated actor also spoke about his absence from Hollywood after his partner Eva Mendes had their second child, saying: “I wanted to spend as much time as I could with them.”