Shameik Moore voices Miles Morales, the web-slinger in the new animated film "Spider-Man: Into the Spider-Verse." CTMG, Inc.; Alexander Tamargo/Getty Images

A few years ago, actor Shameik Moore was watching the “Ultimate Spider-Man” animated series when a new version of the web-slinger appeared on-screen.

“I was like, ‘Wait a second, this guy is black,’ ” Moore tells The Post. “I focused on him harder and realized he looked just like me.”

The character was Miles Morales, a black-Latino version of the classic Marvel character, introduced seven years ago.

And Moore, 23, isn’t talking about the character looking like him in an abstract, representative kind of way. He’s talking about a literal resemblance. Both he and the hero have the same handsome face, the same short-cropped hair.

The resemblance was so remarkable that a fan took a photo of Moore, who had recently starred in the 2015 indie hit “Dope,” and posted it on Reddit beside an image of Morales.

Moore, an Atlanta native, embraced the likeness and began scribbling in his journal over and over, “I am Miles Morales, I am Spider-Man.”

Someone in Hollywood was also paying attention, because Moore eventually became Miles Morales: He voices the character for his big-screen debut in “Spider-Man: Into the Spider-Verse,” out Friday.

He won the role after the filmmakers spotted him in “Dope” and asked him to record an audition tape, in which he read a few pages of the script.

Sony Pictures Animation

The animated film centers on Morales, an outcast Brooklyn teen who gets bitten by a genetically enhanced spider and gains superpowers.

Moore likes that Morales is getting wider exposure.

“We need different kinds of heroes,” the actor says. “It’s important to be represented out in the world. There’s going to be a biracial kid who sees this movie and relates to the character. He’ll feel like [I did] when I saw Miles Morales, which pushed me to write, ‘I am Spider-Man.’ That put me in this position. Hopefully it happens to the next kid.”

The filmmakers were definitely interested in the next thing. The film’s three directors — Bob Persichetti, Peter Ramsey and Rodney Rothman — have said that they wanted Morales to be the focus so that this Spider-Man would be “representative of what it’s like in 2018 America or the world,” Persichetti tells the Guardian.

And the character is inspiring fans.

“It’s justification for your own imagination,” says Omar Holmon, 33, of Crown Heights, who co-founded the website Black Nerd Problems. “It’s like, I’m not crazy for wanting to be that superhero or creating a character like him. You see new routes open up.”

‘We need different kinds of heroes. It’s important to be represented out in the world.’

Peter Parker had been Spider-Man since his debut in 1962. After Barack Obama’s 2008 election, Marvel began to think about introducing a new version of its marquee hero.

Morales hit the comic pages in 2011, before spinning out into other media.

The late Stan Lee always said one of the most attractive things about Spider-Man was that his costume covered his whole body, allowing everyone to imagine it was them under the mask. Spider-Man could be anyone. And now he is.

“These stories affect how we see other people and how we think of ourselves,” says Larry Fellows III, 33, a Morales fan who lives in Bushwick and works in retail. “Especially in a world where young black and brown people feel invisible or often vilified.”