Robin Williams, who was found dead at 63 on Monday in what appears to be suicide, appeared in any number of serious mentor roles in the course of his long career. He was an inspiring private school teacher in 1989’s “Dead Poets Society.” He won an Academy Award for playing a therapist who helped a working-class math genius recognize his potential in the 1997 drama “Good Will Hunting.”

He was in plenty of movies of lesser quality, too, but Williams is arguably one of the actors who influenced young viewers most, whether you got hooked by his father figures or inspired by his stand-up specials. When I learned Monday that Williams had died, though, I thought immediately of one of his stranger performances: children’s performer Rainbow Randolph, who is inspired to homicidal rages by the rise of a competitor (Edward Norton) in “Death to Smoochy.”

“Death to Smoochy” is a difficult movie to defend. It is strange and morbid. It takes a deeply sick sense of humor (and too many repetitions of the “Barney” theme song) to stage a death match between a clown and a guy who dresses up in a plush rhino suit. I do not blame any audiences or critics who recoiled from it at the time. But the movie features Williams doing something he was tremendously good at: bringing a certain measure of dignity to a man in a deeply undignified situation. As Rainbow Randolph, Williams brought a genuinely wounded quality to what could have been a cheap part.

This fine sense of balance emerged in other, better movies in Williams’ oeuvre, sometimes in socially significant ways.

In “The Birdcage” (a 1996 remake of the French movie “La Cage aux Folles“), which came out at a moment when big-budget depictions of gay couples were still relatively rare in American cinema, Williams played a gay nightclub owner, Armand. When Armand’s son (Dan Futterman) becomes engaged to the daughter of a conservative Congressman, Armand and his partner Albert (Nathan Lane) agree to carry out a cruel charade: Albert uses the skills he normally applies to his drag act to pretend to be a woman, and Albert and Armand masquerade as a straight couple.

It is painful to watch Armand try to balance his obligations to his son and to Albert. I have always been struck by one scene in which the two men debate about whether they could pass their relationship off as something it is not. It is simultaneously a very arch and very blunt scene about the ultimate futility of living in the closet.

In 1993’s “Mrs. Doubtfire,” Williams was the one dressing in drag, this time as Daniel, a voice actor who had lost custody of his children to his wife Miranda (Sally Field) and who masquerades as an English nanny so he can find a way to spend time with them.

If the movie were made today, it might founder on increasingly bitter debates about custodial rights. But rather than making Miranda out to be poisonous or controlling, “Mrs. Doubtfire” focuses on Daniel’s deep love for his children, aided considerably by Williams’s performance. By putting on another identity, which ought to be ludicrous, Daniel slips his past bad habits as a father, and instead finds a way to try out being strict but affectionate.

Williams excelled in bring out the strength in characters who initially appeared weak, and in bringing dignity to people mired in hopelessly undignified situations. He also slyly exposed the weakness and selfishness in people who seemed to be strong, even when he was only acting with his voice. As the Genie in Disney’s gorgeous animated movie “Aladdin,” Williams beautifully captured the dilemmas of a being who had access to tremendous power, but had to manipulate other people to get closer to his own heart’s desire. He was critical to making the movie more than kids’ stuff.

In talking to my Post colleague Alexandra Petri tonight, she said she was struck by the breadth of Williams’ roles, and how many of them seem to have resonated in radically different ways. I know that Williams was the actor who taught me that adults were not invincible. Sometimes, as in “Dead Poets Society,” they went up forces bigger than they were and lost. But more often, they battled their own weaknesses and came to honorable compromises. That is a hard lesson to learn, but an important one. Williams conveyed it beautifully.