Toward the end of The Florida Project, a tragicomedy set at a welfare motel next door to Walt Disney World, the film's six-year-old star gorges herself at a hotel buffet for which her wild-child mother, an unemployed lap dancer, won't be able to pay. To capture the scene in which the bold little Moonee prattles away hilariously about the fancy food she's scarfing, director Sean Baker simply let the cameras roll for 20 minutes as the remarkable young Brooklynn Prince improvised.

"She was making the whole crew crack up. We were biting our fists trying not to laugh," Baker said, describing the young actor's performance during an interview at the Toronto International Film Festival last month. Baker fed Prince some lines and egged her on, but the poignant moment when Moonee, who must surely be the product of an unplanned teen pregnancy, wishes she were pregnant so that she could fit more food in her belly, was entirely Prince's own invention.

For all the careful planning that went into shooting a film with three child actors in a real motel in steamy temperatures, The Florida Project is a creation that depended a lot on serendipity. Baker has long admired the Little Rascals, the rampaging children who starred in the 1930s Our Gang film series; his new film was always planned as a direct homage to the Rascals, but Baker was determined he would not make it unless he found his star.

Story continues below advertisement

"I always give myself a definitive, black-and-white, if-I-don't-get-something-I-am-not-making-the-film … If I don't get the new Spanky McFarland [Our Gang's ringleader] I am not doing The Florida Project. I wanted to find Spanky in a little girl, and Brooklynn Prince walked into the [audition] room and blew us away."

Bria Vinaite is cast as her floundering mother Halley, while Christopher Rivera plays her buddy Scooty, a partner for throwing water bombs, tossing a dead fish in the pool and other amusements that will fill the long summer holidays. The two are joined by young Valeria Cotto in the role of Jancey, another six-year-old girl and a new kid in the neighbourhood who needs to be initiated into the ways of motel life.

Baker, who had previously worked with a toddler in his 2008 film Prince of Broadway, had assumed he could direct the three children himself, observe them in a documentary manner and then capture the performances he wanted through editing.

He had shelved The Florida Project to work on Tangerine, his 2015 film about two transgender sex-trade workers, and its success allowed Florida to be made on a bigger budget. As shooting approached, the director quickly realized that with the limited hours the young actors were allowed to work, the hot sun beating down and other people's money at stake, he had better get help. He called in actor and producer Samantha Quan to work as an acting coach.

"She did something I don't think I would have had time to do or known to do. She might not want to hear this, but she was very maternal; she took the kids and she set up what was basically a summer camp for them. There were always workshops, exercises. … They were excited about coming to work every day and by the time we actually got to shooting, these kids were ready, they were prepped: they knew their lines; they knew the blocking; they knew never to look in the camera. … I had to ask two six-year-olds to improvise and they did it, and they held their own with Willem Dafoe [who plays the motel manager]. And they brought stuff to the table that elevated and enhanced what we wrote."

The film's setting, meanwhile, was another bit of luck. Baker had found out about the effects of the 2008 recession in Florida from his writing partner Chris Bergoch, whose mother lives in the Orlando area. "There were news articles that there was a hidden homelessness problem in the shadow of the [amusement] parks. … I started doing research: these budget motels become the last resort before hitting the streets." For a filmmaker, the contrast between fantasy and reality was too a good an opportunity to pass up.

Although the film exposes an underside of Orlando that will be entirely new to many viewers and includes a scene where the homeless cheer as an abandoned condo development goes up in flames, Baker said the local tourism industry was happy to help him. The owner of the Magic Castle, the purple monstrosity where Moonee and her mother live, was particularly co-operative.

Story continues below advertisement

"He went through what [the owner] in the film went through: He had this business that was making money; it got hit by the recession and it's in a place now where it is basically a makeshift welfare motel and he has to deal with it. … He knew how we were portraying it. We were paying him and [the film] might bring business, too, but I think he was also aware that this might shine light on it and what local businesses are going through."

Disney World, meanwhile, makes a fleeting cameo appearance as the place of every child's dreams. It's another example of Baker's clever work around the margins of America's iconic creative industries – the characters in Starlet (2012) include a couple of adult-movie actors, while the hero in Prince of Broadway sells designer knock-offs on the famous street – but Baker sees the recurring themes differently. Like Tangerine's transgender prostitutes and Starlet's porn stars, The Florida Project humanizes Halley's economic plight.

"If it's a trilogy, it's Starlet, Tangerine and Florida Project, in the theme of sex work," he said. "We cover different aspects in each film, asking audiences to look at it in a slightly different way, removing the stigma because the stigma only hurts the sex workers."

"Slightly different" is an understatement; utterly improbably, The Florida Project is a comedy about the effects of housing and income insecurity: "We are trying to do it in a way that isn't overbearing and hitting the audience over the head," Baker said of the choice to go for laughs. "We wanted to do it in a way that was easily digestible, that was through entertainment … through spending the summer with little Moonee."

The Florida Project opens Oct. 13 in Toronto and Oct. 20 in Montreal and Vancouver before expanding to other Canadian cities throughout the fall.