Nothing fires up a basketball crowd than a thunderous dunk, as the Knicks’ Derrick Williams showed at Madison Square Garden Tuesday night.

Twice in the fourth quarter Williams drove baseline for two-handed dunks, doing his part to get the Knicks fans here cheering.

As the Knicks snapped their four-game losing streak with a 108-96 win over the Detroit Pistons, they looked every bit like the cohesive offensive unit that second-year coach Derek Fisher has been talking about in recent weeks.

And never was their collective unselfish play more apparent than on those two similar-looking offensive sets midway through the fourth quarter that led to those crowd-pumping baseline slams by Williams. One pass came from Carmelo Anthony, the other from Langston Galloway.

“I thought the trust level was much higher,” Fisher said.

Anthony led the way with 24 points, 6 rebounds and 6 assists. But what was most impressive on this night was how well the Knicks shared — and scored. They shot 54.4 percent from the field (43-for-79) as six players finished in double figures.

advertisement | advertise on newsday

Williams had 16 of his 18 points in the fourth quarter as the Knicks turned a close game into a much-needed laugher and avoided their first five-game losing streak of the season.

They also did without much help from struggling rookie Kristaps Porzingis, who scored 10 points on 4 of 6 shooting in just 19 minutes. He didn’t play at all in the fourth quarter.

Fisher rode the hot hand, playing Williams over Porzingis in the fourth.

“It was not easy to park him on the side,” Fisher said of Porzingis. “He’s been one of our best players for us this season.”

Anthony, who struggled to find his shot early, beat the buzzer at the end of the third quarter with a baseline jumper. That capped a quarter in which the Knicks extended their one-point halftime lead to seven by shooting 11-for-20.

“It was good to see us put two halves together,” Fisher said. “We haven’t been able to do that much lately.”

Throughout the Knicks’ recent struggles Fisher has stressed the importance of cohesive play, especially on the offensive end. Too often the second-year coach has watched as plays break down because players have not reached a comfort level playing alongside each other.

“We’re still trying to find connection throughout the game,” Fisher said. “We’re still new faces, new players, new tendencies and new habits.”

But Fisher had to have been pleased at halftime Tuesday night with how well the message was received through the first 24 minutes of play. Although the Knicks entered the half with only a 50-49 lead, they played a noticeably crisper brand of basketball than they have of late.

The Knicks had no problem riding whoever had the hot hand, whether it was Kyle O’Quinn (10 straight points spanning the end of the first quarter and start of the second quarter) or Jose Calderon (eight straight Knicks points midway through the first).

advertisement | advertise on newsday

Eight different players scored in the half, exactly the type of shared offense that the league’s best teams are capable of.

Fisher knows that, having played on more than his share of winning clubs. And he also knows the Knicks have lots of work to do before they consistently perform well.

The coach said as much before the game as he tried to explain how the Knicks had started the season with such promising play only to sputter repeatedly in the past month. After starting the season 8-6, they entered Tuesday night’s game having lost 12 of their last 18.

“With the little bit of early season success the excitement has grown and maybe the expectations have grown,” Fisher said. “But the reality is we’re still very much a work in progress in terms of where we are right now.”