Willy Hernangomez was touted over the summer as a foundation player and someone who was a part of the Knicks’ long-term future.

They’re trading the second-year center Wednesday for a seldom-used journeyman and two second-round picks.

The Knicks are sending the 23-year-old Hernangomez to Charlotte for 6-foot-9 forward Johnny O’Bryant and the Hornets’ second-round picks in 2020 and 2021, the team announced on Wednesday afternoon. The Knicks also will create a $1.5 million trade exception with this deal.

“We thank Willy for all of his contributions to the New York Knicks organization and wish him the best moving forward,” Knicks general manager Scott Perry said in a statement. “This trade adds valuable draft picks, better positioning this team as we build toward the future.”

O’Bryant, 24, was a second-round pick out of LSU by the Bucks in 2014.

He’s averaged 3.5 points and 2.4 rebounds in 147 games for the Bucks, Nuggets and Hornets.

In 35 games with Charlotte this season, O’Bryant averaged 4.8 points and 2.6 rebounds over 10.5 minutes.

Hernangomez’s representatives recently spoke to Knicks officials about moving him before Thursday’s 3 p.m. trade deadline if he wasn’t going to get any playing time.

Hernangomez said Tuesday he expected something to happen, and it did less than 24 hours later as the Knicks granted him his wish.

“All I can say is that I want to be somewhere where I can have minutes, where I can play and where I can keep developing,” Hernangomez said before playing 109 seconds of garbage time in Tuesday’s loss to the Bucks. “The only thing I really want is to find the best way for my future before Thursday.”

Hernangomez didn’t want to leave his close friend Kristaps Porzingis, but he was prepared to because as he said, “I really have to play.” Hernangomez appeared in just 26 of the Knicks’ 55 games this season and averaged 9.0 minutes per game.

It’s been a rough 24 hours for Porzingis.

He suffered a season-ending torn left ACL in Tuesday’s game, and now his closest friend is a former teammate.

A second-round pick in 2015, Hernangomez was an All-Rookie First-Team selection last season after averaging 8.2 points and 7.0 rebounds in 18.4 minutes.

Knicks president Steve Mills and Perry wrote in blogs on the team website and told reporters that Hernangomez was a building block.

But when the Knicks acquired Enes Kanter from Oklahoma City in the Carmelo Anthony trade, Hernangomez was squeezed out. He became the third-string center behind Kanter and Kyle O’Quinn.

Kanter is a more skilled scorer and O’Quinn a better defender than Hernangomez.

Coach Jeff Hornacek liked how Kanter and O’Quinn gave the Knicks different looks.

A source said Hernangomez didn’t “go get it” enough in practice and the Knicks wanted to see him “take” a spot in the Knicks’ rotation.

Although this was considered a developmental season, Hornacek said Tuesday there hadn’t been any talk of playing the young players for the sake of playing them.

Hornacek said the culture the Knicks were trying to create was one where players “earn their minutes.”

The Knicks may not be done dealing.

It’s possible they could be changing course now that Porzingis’ season is over.

Originally, the Knicks (24-32) hoped to be able to pick up pieces to help them make a run at a playoff berth this season.

But they’re a season-worst eight games below .500 and have lost their best player for the year.

So they could look to move veterans such as O’Quinn and Courtney Lee.

The Knicks also would like to deal Joakim Noah.

Unless they sweeten the pot with a young attractive player or perhaps draft picks — they’re not expected to trade their own No. 1 choice — it could be difficult to move Noah. He is owed $37 million over the next two seasons, and has only played in seven games this season.

Noah has been away from the Knicks since Jan. 24, after he and Hornacek had a heated argument in Denver.

The Knicks said Noah would be gone “until further notice.” Their hope is that they can trade him.

Otherwise it’s unclear if or when he will return to the team.

If the Knicks opt for the full rebuild now, it stands to reason that Hernangomez might have gotten more of an opportunity going forward.

But Kanter likely will still be a Knick next season.

He has an $18.6 million player option that he could pick up.

Hernangomez could have remained out of the rotation.

Yahoo Sports first reported the Hernangomez trade.