“Sonic the Hedgehog” features, from left, Tika Sumpter, James Marsden and, in the role of the CGI title character, Ben Schwartz. (Paramount Pictures/Sega of America)

Rating: (3 stars)

Ah, the joy of a kids’ movie that doesn’t have any fart jokes.

Or at least one that comes close. “Sonic the Hedgehog” may have one moment of flatulence, but this hybrid of live-action and CGI animation gets away with it, otherwise bypassing the all-too-common cheap laughs for a story that’s loaded with smart humor, snappy dialogue and the big blue heart beating at its center.

Inspired by the popular series of video games, “Sonic” tells the eternal tale of a blue hedgehog from another planet who runs at near-warp speed. After a relatively pointless exposition — there are a lot of plot elements audiences will just have to roll with — Sonic (voiced by Ben Schwartz) arrives in a small Montana town named Green Hills, where he has to hide his speed, because otherwise people will want to steal it. (Again: just roll with it. Green Hill Zone is the first level of the original video game.) There, he lives a solitary existence, peering into the lives of the townspeople into an attempt to assuage his loneliness.

During a one-man baseball game, Sonic runs fast enough to produce an electronic pulse that not only knocks out the town’s power, but causes satellites to go wonky, attracting the attention of some vaguely menacing government figures. Along with said government figures arrives Dr. Ivo Robotnik (Jim Carrey), a brilliant, slightly bent scientist now fixated on tracking down and experimenting on our fuzzy friend. In an effort to escape from Robotnik, Sonic teams up with the town’s sheriff, Tom (James Marsden), with whom he hits the road to San Francisco in search of a lost bag of rings that enable Sonic to travel between planets. (Remember: roll with it). Now that Sonic has been spotted by the Feds, it seems he has to head off-planet for his own protection.


Sonic (Ben Schwartz) in “Sonic the Hedgehog.” (Paramount Pictures/Sega of America)

These shaky plot elements exist only to set up Sonic and Tom’s westward odyssey. Luckily, the destination is worth the journey. Sonic is grateful to have someone to converse with — when he’s on his own, he talks to himself — and that sweetness tames what could have been a character built solely on snark. Sonic’s engaging and expressive face, combined with Schwartz’s always-excellent voice acting, creates a character worth rooting for. Marsden is charming as he goes through the traditional arc usually found in this type of movie: first, bewilderment at his discovery of Sonic; followed by a desire to help him get off the planet; and ultimately ending up with a sincere friendship.

While most of the secondary characters are so lightly written that they nearly float, Carrey’s Robotnik — played by the hyper-energetic actor operating at maximum strength — makes for an egotistical, slightly unhinged villain, whose fundamental weirdness is fun to watch, without ever being really scary (a boon to parents with younger kids). This version of Carrey has been missing from screens for a while. The last time we saw anything remotely similar was in 2014’s “Dumb and Dumber To.” It’s easy to forget that his rubber-faced antics do work when used in the right setting.

Sonic, whose computer- ­animated appearance in the movie’s first trailer led to widespread protests by fans that the character didn’t look quite right, resulting in a delayed release date, has since been honed into a creature who really seems to occupy the same physical universe as the human characters. (It probably helps that he rarely touches any of them). Jeff Fowler’s direction keeps the movie moving at a brisk pace and includes a few scenes that are creative enough, visually, to be truly impressive.

There are a couple of misses: It’s probably time to retire the Queen song “Don’t Stop Me Now” as the Official Tune of Action Montages. And we could do with one fewer Sonic-is-so-fast-that-everyone-else-looks-frozen-in-place scene.

Fans of the video games will find a host of allusions, but there’s plenty to please any moviegoer who can’t tell a Sega from a Switch. In the end, “Sonic” is quippy without being mean, and sweet without being sappy, making this a trip that’s well worth taking.

PG. At area theaters. Contains action, some violence, rude humor and brief mild language. 100 minutes.