If I didn’t know better, I’d swear “Megamind” was the work of people who were making it up as they went along. The story doesn’t “build” so much as it meanders from one scene to the next. I picture a little kid improvising a story: “So THEN the bad guy beats the superhero, but THEN the bad guy is bored because he doesn’t have anyone to fight, so THEN he decides to make a new superhero for him to fight, but THEN….” Not bad, exactly, but not the kind of precision and craftsmanship you’d expect from something that takes three years to make.

Our protagonist, Megamind (voice of Will Ferrell), a bald, blue, eggheaded being, came to Earth as an infant, under circumstances very much like those that brought Superman here. Another alien baby arrived at the same time, though. That one landed in a wealthy home with loving parents and grew up to be the truly Superman-like Metro Man (Brad Pitt). Megamind, on the other hand, landed at the “prison for the criminally gifted,” where the inmates raised him as one of their own to become a supervillain.

As adults, Megamind and Metro Man battle regularly. The villain kidnaps TV reporter and Metro Man girlfriend Roxanne Ritchi (Tina Fey); Metro Man rescues her and puts Megamind in jail; Megamind breaks out and does something else dastardly; you know the routine. Just as Metro Man is being honored with a huge statue and museum in downtown Metro City, Megamind enacts his latest scheme and — what do you know — actually succeeds in getting rid of Metro Man. Huh. Well. What now?

What now indeed. Defeating the hero is every archenemy’s dream, but as the premise for an actual story it’s problematic. Are we to be consumed by the villain’s existential angst when he realizes he’s nothing without his enemy? Will he actually take over the world and enslave humanity? Is he really evil, or just cartoon-character-supervillain evil? How much realism, exactly, do we want to bring to this comic-book silliness? Surely not much — but what, then?

“Megamind,” written by first-timers Alan Schoolcraft and Brent Simons and directed by Tom McGrath (“Madagascar”), tries a bunch of things, some good, some not as good, some funny, some less funny. Megamind and his henchman, Minion (David Cross), are an amusingly goofy pair, but the plot thread where Megamind assumes a mild-mannered secret identity and woos Roxanne while one of her schlubby co-workers (voiced by Jonah Hill) pines for her is just convoluted.

But it’s considerably less aggressive and in-your-face than a lot of the DreamWorks animated films have been, maybe because Will Ferrell is a softer and more relaxed presence than, say, Ben Stiller (who almost took the part and serves as executive producer). As a character, Megamind is endearing, with his mispronunciations and hopeless plans, not to mention his secret crush on Roxanne Ritchi. At one point she observes that “Megamind would never run away from a fight, even when he knew he had absolutely no chance of winning.” Like Wile E. Coyote, he is persistent in the face of defeat. It’s kind of admirable, really, if you think about it.

And so “Megamind” winds up being a pleasant-enough story about redemption, about choosing to be the person you want to be regardless of what others expect of you. I’d like it a lot more if those Pixarian themes had been developed with greater care; as it is, they come across as an afterthought. The gags, meanwhile, range from the modestly humorous to the mildly dumb. It’s a harmless, inoffensive, moderately likable throwaway of a cartoon that you will probably start forgetting as soon as it’s over.

B- (1 hr., 36 min.; PG, action peril and mild crude language.)