NEW ORLEANS — In a move to add salary-cap space, the Houston Rockets traded forward K.J. McDaniels to the Brooklyn Nets on Thursday afternoon just before the 3 p.m. ET trade deadline, according to a source.

The Rockets also traded Tyler Ennis to the Lakers in exchange for fellow guard Marcelo Huertas, a source said. Houston is expected to waive Huertas.

The trades will give the Rockets $3.5 million in cap space, which a source said they will use in an attempt to sign players who have been bought out.

McDaniels, who’s 6-foot-6, 205 pounds, just couldn’t get into coach Mike D’Antoni’s rotation and played 212 minutes in 29 games. At the start of the season, D’Antoni wanted McDaniels to become a wing defender, but he struggled falling behind Corey Brewer and Sam Dekker at small forward off the bench.

Last month, McDaniels was almost traded to Cleveland for Mike Dunleavy Jr., but the Rockets pulled out of the deal. Instead, Dunleavy was eventually traded to the Atlanta Hawks for Kyle Korver.

McDaniels said at the time he understood the business of the NBA, and despite limited playing time, his goal is “to remain ready.”

In the summer of 2015, McDaniels signed a three-year, $10 million contract as a restricted free agent with the Rockets. The objective was for McDaniels to get significant playing time, but that never occurred.