Toy Story 4 producers Mark Nielsen and Jonas Rivera recalled Tom Hanks' reaction to the ending of the film, telling RTÉ Entertainment that it gave them confidence in the script.

Hanks, who first took on the role of voicing Woody in 1995's Toy Story, previously said he had to "take a moment to collect myself" after reading his final lines in the series' fourth instalment, and the producers said seeing him react emotionally like that gave them "confidence" that it would work.

"I remember Tom, pitching to him, and him going, 'Really? Oh.' And we could see his reaction, like oh that got him, he didn't expect that," Rivera told RTÉ Entertainment.

"At the end of the day you want the audience to get something they're not expecting so I remember that and us going, 'Ok, I think we have something'."

Nielsen added, "It's like a receipt of all of these years we've been spending on getting it right with these characters.

"It's incredible to have them react to it, they're one of the first audiences because we work for years on these stories before we introduce them and pitch them the movie to see what they're going to think of it.

"So there's a day when we do that pitch and we're  like, 'I hope they like this and want to go on this ride with us' and so having them buy into it was huge for us."

Toy Story 4 is released on Friday, June 21.