Character in 'How to Train Your Dragon 2' comes out as gay

Is the world ready for its first animated gay Viking?

"How to Train Your Dragon 2" sure hopes so.

"How to Train Your Dragon 2" opened at the Cannes Film Festival last week with its stars in tow, a big party on the beach, and a life-sized Toothless the Dragon hanging out for photo ops with reporters.

The sequel to its $500 million blockbuster predecessor has a lot to prove, with the kid movie’s star Hiccup (Jay Baruchel) now a young man, and the Vikings vs. dragons conceit of “Dragons 1” rendered effectively moot as the dragons and Vikings have become best of pals.

But not even writer/director Dean DeBlois was able to cook up one of the new movie’s most surprising twists.

Gobber is gay.

“It wasn’t that deliberate. It was an ad-lib that Craig Ferguson added,” DeBlois told FOX411.( The talk show host is the voice of Gobber in the film). “I’d written the line ‘This is why I never married.’ And then he had tagged that on to it.”

Ferguson tagged on ‘That, and one other reason,” seemingly a reference to gay marriage, which has only recently become legal in several states.

“And we all started chuckling and said that’s right, Gobber’s coming out in this movie,” DuBois laughed. “I just love that about Craig. He’s always got just a little extra something for you. I think it’s nice. It’s progressive, it’s honest, and it feels good, so we wanted to keep it.”

The ad-libbed one-liner will now need to be written into Gobber’s role in Part 3, which DuBois says he has just started outlining.

“It does make for an interesting revelation because now, what does that mean, do we shed a little more light on Gobber’s love life?” DeBlois asked.

Featuring more adult themes is nothing new for his “Dragon” series, DuBois says.

“It’s my personal crusade, I want to break down the stigma that animation is just for kids,” he said. “I love "The Empire Strikes Back" as much today as I did when I was a kid. My ambition is to try to create a story that has that kind of reach, that stays with you whether you’re an adult or a kid. In doing so we try to incorporate elements of the story that will speak to the youngest audience members while we’re trying to speak to the adults in the audience as well.”

One audience member who go the Gobber joke? Star Jay Baruchel, who took in a screening.

“Yeah I did. There’s a little – I think it’s open to interpretation,” he told FOX411. “Preaching tolerance in any respect is never a bad thing. I don’t know if drawing a massive amount of attention in the middle of a kid’s movie is, like, necessarily what you should be doing, but listen, if somebody catches it, then good for them.”

Fox Studios did not respond to a request for a comment.