TORONTO -- "Spider-Man" star Andrew Garfield says it was "humbling and horrifying and heartwarming" to live in a Florida motel alongside evicted families to prepare for his role in the home-foreclosure drama "99 Homes."

"It was important and it was vital," he said Monday during an interview at the Toronto International Film Festival.

Directed by Ramin Bahrani ("At Any Price"), "99 Homes" features Garfield as Dennis Nash, a down-on-his luck Florida construction worker who is evicted from his home and takes a job with a morally dubious realtor (Michael Shannon) to support his mother (Laura Dern) and young son (Noah Lomax).

Bahrani, 39, said reaction to the film -- which received raves at the recent Venice Film Festival -- has been visceral. Audiences, he said, have been "in tears and in rage and in compassion."

"The whole world was turned upside down economically by what started in Florida, which is where my film takes place," said the director. "So I went down there and spent time with fraud attorneys, with realtors going on evictions, in foreclosure courts ... with thieves, hoodlums, crooks (and) wildly rich hedge-fund managers. The corruption was just mind-boggling.

"What became the heart (of the story) was the very normal middle-class families ... living in motels on the road to Disney World. ... So normal. Not poor. Middle-class, normal families living in hotels with their kids."

Garfield, 31, bunked down for two weeks in one of the motels Bahrani visited. There, he saw families sleeping in the lobby or in a conference room.

Those families could be anyone, the actor said Monday as he discussed why the film appealed to him.

"What drew me to (the role) was something that I needed to heal within myself, and therefore I knew that a lot of men and women needed to heal this aspect too," said Garfield. "I think we all crave community and we all need community. It's a very natural instinct for us all to come together and take care of each other. But we've been sold some other idea ... that it's every man for himself and if I don't win, someone else (will)."

Shannon's character, Garfield added, is a "symbol of separation, the anti-community, the hierarchy, the capitalist structure, the ability to separate."

Bahrani has high hopes for what "99 Homes" can achieve.

"I hope the film can be a chance ... for us globally to reassess our moral fibre and what's happened," he said. "The powers who have made the world this way are very strong, but they're very few (in number) ... the mass of people has to change things."

The film is dedicated to Roger Ebert, who was a champion of Bahrani's career. For years, the late critic was a fixture at the Toronto International Film Festival, and Bahrani said he dearly wishes his friend could have seen "99 Homes."

Said the director: "I want to know what he thinks. He said such amazing things about me and I always feel I have to live up to that."

The Toronto International Film Festival runs until Sunday.