Going into Sonic the Hedgehog can be a treat for long-time fans of the franchise. But the biggest takeaway from the film is that Jim Carrey makes for a perfect Doctor Robotnik. He’s a bizarre but brilliant bad guy, and Carry goes all-in on the character in order to find the perfect balance between goofy and devious.

Sonic the Hedgehog writers Pat Casey and Josh Miller spoke to The Illuminerdi about how excited they were when Jim Carrey came onto the film, and just how much of the character of Robotnik was defined by the legendary comedy actor.

RELATED: SONIC THE HEDGEHOG WRITERS ON FINDING THE HUMANITY IN THE HEDGEHOG

Sonic the Hedgehog Robotnik

PAT CASEY & JOSH MILLER TALK JIM CARREY IN SONIC THE HEDGEHOG

Was there anyone else who could have played the role of Doctor Robotnik besides Jim Carrey?

Josh Miller: I don’t think anyone could have made it work the way he did. As far as his name coming up, it feels dumb to say with a big-budget movie, but I don’t think [Casey] and I ever assumed we could get someone like Jim Carrey.

Pat Casey: It had mostly felt like he had dropped out of movies, and when we heard that he liked the script and wanted to do the movie, our jaws kind of dropped.

Josh Miller: We heard they were offering it to him, and we were like… it’s mind-blowing that he did it. In some ways, the Sonic generation and the Jim Carrey generation overlap if you’re a 90’s kid.

Pat Casey: We grew up playing Sonic games and seeing Jim Carrey movies. And now here we are. It’s very surreal.

Where did the relationship between Robotnik and Agent Stone come from?

Josh Miller: We’re proud enough of the movie that we’re happy to push the credit around. Most of that stuff Carrey and Lee Majdoub [who plays Agent Stone] came up with on set. For some reason, Jim really locked into this relationship. All the things with the coffee, the great bit where he punches him and says ‘you left yourself open’. That was just them fleshing these characters out.

RELATED: SONIC’S BEN SCHWARTZ HYPES HEDGEHOGS, GAME GEAR AND THE KNICKS

Sonic The Hedgehog Writers Reveal How Much Of Jim Carrey's Robotnik Was Improvised - The Illuminerdi

One of the most interesting things about Robotnik as a character is how, despite how manic and menacing he can be, Jim Carrey almost makes him likable despite that.

Josh Miller: That’s why it’s difficult to imagine anyone else doing it, because we definitely had [conversations while writing the script] was how funny versus how intimidating do we make him. But Jim really perfectly straddled that. He’s like, an intense guy so he’s got that good crazy villain focus. But then he’s the funniest guy in the world.

Pat Casey: There was a thing, where people at the studio would ask ‘do we make him funny, does that take away from him being intimidating?’ It’s not one-versus-the-other, it’s possible to be both at once if you have a performer that can do that. The other thing that Jim brought that I think is great is that he really appreciated Robotnik’s inner vulnerability. He really understood the idea and wanted to play it, the idea that whatever happened to him in the past… Robotnik is a deeply wounded person, which is why he’s acting out this way.

Josh Miller: Jim added a lot of that stuff to the script, which was great to see him coming up with all these ideas. Because you get someone as big as Jim Carrey, you’re just wondering like, does he have to buy another house or something? Is this just another paycheck? But he was super invested on the development of the character. He was really excited about the idea of a whole franchise to build off this, what more he can do with the character.

Sonic the Hedgehog is in theaters nationwide.