Note: This article contains spoilers for Pixar’s Up, Dreamworks’s Kung Fu Panda, and Pixar’s The Incredibles.

It’s undeniable that villains have fans, sometimes even more fans than the heroes. But what is it that makes a villain memorable, beyond the awesome songs and general badassery? What makes a villain an essential part of a story?

A great villain is facing the same problem as the hero. Both the hero and the villain have a way of dealing with the problem – sometimes the same way, sometimes a different way. In order for the hero to win, they must overcome the problem in a better way than the villain.

Animated films in particular use this hero-villain dynamic to great effect. For example, in Pixar’s Up, Carl Fredricksen (the hero) and Charles Muntz (the villain) both have the “can’t let go of old dreams” problem. Carl is fixated on fulfilling his childhood promise to take his wife Ellie to Paradise Falls, and Muntz is still – after an implied seventy years! – obsessed with capturing the elusive bird and regaining his reputation as a great explorer. For both men, the focus on the old dream holds them back from having any new ones, or even recognizing any path towards happiness besides the one they’ve trod for so long. Muntz never lets go of his old dream, but Carl finally does – which allows him to defeat Muntz, rescue his friends, and go off on new adventures.

Pixar isn’t the only studio that follows this formula, of course. Dreamworks’s Kung Fu Panda focuses on two characters – Po (the hero) and Tai Lung (the villain) – who share a “self-worth” issue. Despite Po’s happy-go-lucky demeanor and Tai Lung’s constant displays of strength, and their shared dream of becoming kung fu masters, over the course of the movie it becomes clear that they each don’t think very much of themselves. Though selected as the “dragon warrior,” Po doesn’t believe himself worthy of it. And despite Tai Lung’s great skill, he took being denied the secrets of the Dragon Scroll so personally that he waged war on his home, and to this day seems desperate to beat approval out of his father-figure Shifu. Po finally gains the ability to defeat Tai Lung when he learns that there is no “secret ingredient” to greatness – the Dragon Scroll is blank. Tai Lung insists to the end that there must be a secret that he is being denied access to. And, in the end, Po emerges on top.

Let’s return to Pixar for one more example – The Incredibles, because I’m so excited about the upcoming release of Incredibles 2. In this movie, Mr. Incredible and Syndrome have an “obsession with glory” problem. For most of the film, both characters prioritize the glory associated with being a hero over the “do good and help society” aspect. Mr. Incredible repeatedly puts his family’s safety at risk in order to relive the “glory days.” Syndrome flat-out kills all other supers so that he alone will have the world’s adoration.

As a matter of fact, every character in this film has some connection to this conflict between prioritizing glory or good. A cape looks cool, yes, but as Edna Mode will vehemently tell you, it is not safe, and certainly not worth risking your life and loved ones for – but she leaps at the chance to “design for gods” once more. Elastigirl firmly prioritizes the safety of her family over the thrill of hero work, which has the unfortunate side effect of raising children who have never been free to explore their full potential. Having all characters tied to a film’s central issue helps make everything feel purposeful and linked together, as one coherent story.

By the end of the film, Mr. Incredible gets his priorities straight, and works together with his family to find the proper balance between being great and doing good. Syndrome, on the other hand, puts the public good, the safety of the people close to him, and his own safety so far down his list of priorities that it kills him.