Moving to a new city is never easy. You have make new friends and learn your way around. But adjusting to big changes can be especially hard for preteens — a time when positive emotions typically take a nosedive — and the new Pixar movie Inside Out brings to life the emotions an 11-year-old girl experiences after her family moves.

Getting the emotions right — what they look like and the purpose they serve — was important to the movie, and psychologists Dacher Keltner of UC Berkeley and Paul Ekman of UCSF, who are authorities on human emotion, signed on as consultants on the film.

In meetings with Pixar writer and director Pete Docter, they discussed the science that informed how emotions work inside a person’s head and shape a person’s social life.

“Our conversations with Mr. Docter and his team were generally about the science related to questions at the heart of the film,” write Keltner and Ekman in “The Science of ‘Inside Out,'” in the New York Times this past Sunday. “How do emotions govern the stream of consciousness? How do emotions color our memories of the past? What is the emotional life of an 11-year-old girl like?”

In the film, the audience gets to peer inside the head of Riley, who has just moved from Minnesota to San Francisco with her family. Five emotions — personified as the characters Anger, Disgust, Fear, Sadness and Joy — struggle for control in her mind, and although joy is the primary emotion that defines her personality, it’s sadness that takes center stage.

“Inside Out is a film about loss and what people gain when guided by feelings of sadness,” write the scientists. “Riley loses friends and her home in her move from Minnesota. Even more poignantly, she has entered the preteen years, which entails a loss of childhood.”

Although sadness is made to play the role as a sluggish emotion, say the psychologists, it actually serves to pull people together and reunite in the face of loss. The central insight of Inside Out, they say, is to “embrace sadness, let it unfold, engage patiently with a preteen’s emotional struggles.”

Read the New York Times article.

Read our earlier interview with Dacher Keltner on Inside Out.