CHARLOTTE, N.C. — Maybe there are just no storybook endings left in this Knicks’ season.

With RJ Barrett struggling immensely, forgotten man Allonzo Trier came off the bench midway through the third quarter with the Knicks down 13 Wednesday night.

Trier led a fiery comeback, getting the Knicks within two points in the closing minutes. But he couldn’t sink the potential game-tying 3-pointer with 56 seconds left as the Knicks fell to the Hornets, 107-101, at Spectrum Center.

It was the Knicks’ fifth straight loss, dropping them to 17-41, and interim coach Mike Miller appeared angrier than he’s been after any loss. The losing streak is a high for Miller’s stint and a new president, Leon Rose, is to start as early as Sunday.

The Knicks trailed the entire second half, but Trier, the second-year man who mysteriously has been out of the rotation virtually all season, pumped in 15 points on 6 of 8 shooting in his 16 minutes — going 1 of 2 from 3.

Asked if it’s tough to sit the first 34 minutes, then come in cold, Trier said, “Absolutely. You got to come in and catch the flow. Sometimes you don’t and you look bad. You got to be a pro. … It was great to be running around being in the game. I’ve played my whole life to be in this position.”

Miller was desperate for scoring as Barrett had a rough night. The rookie finished with five points on 2 of 11 shooting and was benched in the final period in favor of Trier. Miller also benched Julius Randle in the final frame for Bobby Portis (17 points).

Allonzo Trier, who scored 15 points off the bench, shoots a jumper during the Knicks' 107-101 loss o the Hornets.
Allonzo Trier, who scored 15 points off the bench, shoots a jumper during the Knicks’ 107-101 loss o the Hornets.NBAE via Getty Images

“We had some guys who really played well in the fourth quarter,’’ Miller said. “They were sharp together. Randle had solid game but we were rolling with that group.”

Randle bolted the locker room before reporters were let in. Miller usually never uses negative language despite all the losses but couldn’t help himself after losing to Charlotte (20-38).

“We had probably 25 minutes in there of really inconsistent play,’’ Miller said. “We put ourselves in that position and had to come back and almost be perfect. Our margin of error when we came back was zero. It’s a 48-minute game and you have to play both halves.’’

Trier, who showed life in Houston on Monday when he came on in garbage time to score nine points in six minutes, lit up the sagging offense. He drove baseline and scored despite contact to make it 97-95 with 2:43 left and hit another 20-footer to get the Knicks within 100-97 with 1:14 left.

But with a chance to tie, Trier’s corner 3 bounced off the rim. The Knicks were still down just 3 when starting point guard Elfrid Payton, who had a miserable game, turned the ball over on a drive with 46 seconds left.

Payton, who had missed the last two contests with a sprained ankle, finished with six turnovers.

Barrett had one of his roughest first halves of the season — going scoreless, shooting 0 for 6 from the field. His touches were down with Payton at point guard and Barrett also got lax on defense. Barrett failed to get after Charlotte point guard Terry Rozier, who buried an open 3 and went on to score 26 points.

Dennis Smith Jr., who played at North Carolina State, was terrific in his first minutes of the night, getting to the rack at will and throwing down a monster tomahawk jam. Smith leveled off, playing 21 minutes and was 4 of 12 from the field for nine points and three assists.

Miller decided not to use shooting guards Damyean Dotson and Wayne Ellington, giving Trier the third-quarter audition that just might open the interim coach’s eyes.

“We have a lot of guys we can play,’’ Miller said. “[Trier’s] been sharp since he came back, used his [All-Star] break and really worked on his game. We had a real need for him. We went down our lineup. We gave guys opportunity and we felt like we needed scoring, shooting and playmaking.”

Portis said he wanted to “commend Allonzo for staying ready. It’s been a long year for him being up and down and out of the rotation and then having an impact like that — that’s big.”

On Tuesday, Trier said he has remained “confident’’ despite the adversity, adding “I like what I bring to the table.’’

Trier, last season’s rookie surprise, brought it Wednesday.

“I continue to work on my craft every day and be the consummate professional and support my guys,’’ Trier said. “And if my number is called, I try to be productive.’’