Leonard Nimoy pulled himself out of a semi-retirement to portray Spock for the first time in nearly two decades when he appeared in 2009’s “Star Trek,” and again four years later in “Star Trek: Into Darkness.”

So it’s only fitting that Nimoy’s passing last year finds its way into “Star Trek: Beyond,” and director Justin Lin says he couldn’t move forward without it.

“It’s something you’ll see in the film,” Lin told Film Journal International, according to TrekCore. “It obviously affected everybody because he’s been a big part of our lives. There’s an attempt to acknowledge that in some way.”

Lin also acknowledges that he was asked to step in to save the third reboot Trek film before it imploded, calling his entrance onto the scene as a “rescue mission.”

“I think something had gone wrong, and they wanted to start over,” Lin said. “After Fast and the Furious, I was kind of done coming in on the third film in a franchise. But if there was going to be a franchise where I’d do it, it would be this one.”

Roberto Orci, who co-wrote the first two films under J.J. Abrams, was in line to direct the third installment after Abrams stepped away to do “Star Wars: The Force Awakens.” He even had a story and a script developed. However, Orci was abruptly pushed out of the project during pre-production, according to reports, and Paramount Pictures scrambled to find a director who could pick up the pieces.

“I’ll be very clear,” Lin said. “I don’t know what came before me. We basically had to start over, and that was one of the selling points for me: we had to start from scratch. A clean-up mission wouldn’t have excited me.”

The new mission was something Abrams called Lin and laid out.

“It was J.J.’s call that jarred something in my head, and I realized that Star Trek is a big part of me,” Lin said. “It was something I was invited to do, and I was happy to accept.”

The teaser trailer Paramount released last December appears to not only put the USS Enterprise through more hell than it received in “Into Darkness,” but many believe the ship actually gets destroyed.

“I didn’t come in saying, ‘Let’s destroy,’ it was more like, ‘Let’s deconstruct,'” Lin said. He worked with writers Simon Pegg and Doug Jung on a new story involving this concept, with all of them feeling “that with this being the 50th anniversary of Star Trek, let’s deconstruct it and hopefully rebuild it in a way that reaffirms why we’ve loved it for half a century.

“That conversation went a lot of different places, and one of the most interesting places was the Enterprise itself.”

The full interview can be found in the print edition of Film Journal International.

“Star Trek: Beyond” premieres July 22.