A Sunset Park native says goodbye to Gotham.

With the hit FOX show ending after five seasons, J.W. Cortes, a Marine veteran who was born and raised in Sunset Park, and who has played Detective Carlos Alvarez since 2014, saluted the series, and looked back on his part in it.

The show takes place in the fictional city of Batman lore and includes his gallery of iconic villains, during Bruce Wayne’s childhood, before he became the city’s vigilante.

“I just feel incredibly grateful that I was able to be a part of something that I think will live on for many more years, especially in syndication,” he said. “To be a part of that feels great, and I’m glad and thankful that they kept writing for my character. Obviously, it’s a bittersweet feeling to know that the people you have grown to love like family, you won’t get to see them as often, and that’s taking a bit of getting used to. But I just have to believe that we will see each other again or work again on something else.”

Once he landed the role of Alvarez, his career and life both changed, said Cortes, who used to live on 49th Street between Fifth and Sixth Avenues, an area that was once known for its rising crime.

“It’s affected me how the fans show how much they appreciated catching glimpses of Alvarez over these five seasons,” he explained. “They tell me on social media and I converse with them. They send me fan letters from all over the world. They’ll draw [pictures of] me and they’ll say that they really connect with me because I look like them, especially my fans in Mexico, Latin America, and even parts of Europe. That has been a tremendous opportunity that doesn’t fall lightly on me. I understand the responsibility that I have as well.”

People also recognize him when he’s in the street.

“At least one or two times a day, people will stop and look at me and say, ‘Man, you look just like Detective Alvarez,’” he said.

One of the most memorable moments of his time on “Gotham” was the final scene of the show.

“There’s a really special moment between Morena Baccarin and Ben McKenzie,” Cortes said. “I don’t want to give away any spoilers but those two have a beautiful and tender moment. That was the last scene we shot. The way it all came together, you couldn’t have written a better scene and we all hugged and cried and laughed and partied, but it was as beautiful a send-off as anything I could’ve even imagined.”

Throughout the five seasons, there have been great moments for Cortes but it was tough to pinpoint a highlight.

“I worked on a total of 32 episodes,” he said. “It’s hard, but I will say the biggest unexpected response for me and my character is when Alvarez was affected by the Alice Tetch virus and viewers thought I had been killed. They were sending me messages saying they were real upset. It was nice that I didn’t die.”

Growing up in Sunset Park, Cortes was always a big fan of the characters.

“I was a huge fan of the original Batman with Adam West,” he said. “The Joker was obviously played by a Puerto Rican actor, Cesar Romero. He was phenomenal. Fast forward to all the modern renditions of the story. I’m a tremendous fan of Batman and Punisher. I collected comics. I’d go to Ninth Street and Sixth Avenue, and spend my allowance money on comic books. I believe in the power of them too. They can give us some sort of hope sometimes.”

Although his role was fulfilling, Cortes likes to focus on giving back to the community.

“What really fills my heart is when I was principal for the day at Charles Dewey Middle School,” he said.

In addition, he recalled, “I got to visit St. Jude’s Children Hospital.”

Also, he said, “I’ve given commencement speeches at some of the schools that I went to. That and seeing the young kids who will hopefully carry that message with them, that is far more rewarding than anything I do on any set. And being from Sunset, where there aren’t that many people working on television, I hope they look to me and say, ‘Wow. He’s one of us.’”

“Gotham” airs on FOX Thursdays at 8 p.m.