Pixar’s latest film takes us inside the mind of an 11-year-old girl. Our critic Nicholas Barber started out unconvinced – but was well and truly won over by the end.

There’s a sublime sketch in Woody Allen’s 1972 comedy, Everything You Always Wanted to Know About Sex (But Were Afraid To Ask), which is set inside a young man’s brain. His mind, it seems, is actually a command centre where a dedicated crew is busy adjusting his behaviour. It’s a conceit which has been revived – with a lot less emphasis on procreation – by Pixar’s fizzy new cartoon, Inside Out.

Taking us inside the head of an 11-year-old girl named Riley, the film introduces us to the five sprites who govern her emotions. The leader of the team is a chirpy Tinkerbell lookalike, Joy  – voiced by Amy Poehler, and not a million miles away from the ultra-positive control freak she played in Parks & Recreation. Her four co-pilots are the mopey blue Sadness, the grouchy red Anger, the fretful purple Fear and the snooty green Disgust. Together they stand at a console in Riley’s ‘headquarters’, peering at a monitor which shows them everything she sees, and taking it in turns to influence her.

But Joy is the one who rules the roost and Riley is very happy living in Minnesota with her loving parents. (Like so many children in American films, she’s an only child.) But when the family moves to San Francisco, away from her friends and favourite places, Sadness starts to make her presence felt. Soon, the headquarters are in chaos, and Joy and Sadness are flung out into the mental wilderness which surrounds it. Roaming this strange, extra-terrestrial terrain, they get lost in the maze of shelves where Riley’s memories are stored, they visit the sound stage where her dreams are performed, they bump into her long-neglected imaginary friend, and they take a ride onher Train of Thought. Now Joy and Sadness have to get back to headquarters before Anger, Fear and Disgust turn Riley into a completely different person.All of this is set up with the flair and wit you would expect from Pixar, although not with the clarity of the studio’s finest work. The director of Inside Out, Pete Docter, also made Monsters, Inc, but while that was built on the elegantly simple concept of children’s screams providing energy for monsters, Inside Out isn’t so straightforward. There’s not much logic to Riley’s byzantine, Charlie-and-the-Chocolate-Factory brain. And there’s no compelling reason for Joy and Sadness to be wandering through it. Instead of thinking, “Ah, my mind is just like that,” I kept wondering why Riley’s Imaginationland was so distant from her Personality Islands, and why all the devastation going on in her cerebral cortex hadn’t reduced her to a catatonic wreck. For that matter, why are her moods controlled by Joy, Sadness, Anger, Fear and Disgust? Aren’t Fear and Disgust fairly similar? How come Pride or Envy or Desire aren’t at the console? And, anyway, isn’t it a bit creepy of Joy and her colleagues to keep saying how much they love Riley when she’s essentially an automaton who does their bidding? On Inside Out, Docter and his collaborators are more intent on throwing in every possible wacky idea than they are on weaving those ideas into a cogent whole.

Luckily, there is so much knockabout fun going on that you can’t stay distracted by Riley’s baffling cognitive mechanisms for long. Inside Out is Pixar’s most cartoony cartoon, so to speak. It’s the first one in which the studio has taken full advantage of the medium’s outlandish possibilities, and indulged in the surrealism of the most experimental Bugs Bunny and Daffy Duck shorts. It also has more gags-per-minute than almost any other Pixar film – or any other film, full stop. The cleaners who tidy Riley’s memory shelves are a terrific creation: they clear away four years’ of piano lessons, but they leave an infuriatingly catchy advertising jingle behind. 

The film is always entertaining, then, but it’s not until the last half hour that everything clicks into place. As Inside Out hurtles towards its conclusion, all the disparate jokes and concepts coalesce into a focused narrative at last, and suddenly we’re watching a moving, challenging, and quite profound coming-of-age story. Inside Out has the perfect, uplifting ending of a classic cartoon. I just wish it hadn’t taken such a roundabout route to get there. In the first half of the film, I was being piloted by Confusion and Dissatisfaction. But by the end, Joy was very much in charge.

★★★★☆

If you would like to comment on this story or anything else you have seen on BBC Culture, head over to our Facebook page or message us on Twitter.