The Knicks wanted to erase the memory of what happened in their last game, but no one was more motivated than Arron Afflalo.

The veteran guard had been in a shooting slump and was nonexistent in the Knicks’ 27-point loss to the Bulls on New Year’s night. But he made his presence felt early and often against the Atlanta Hawks on Sunday at the Garden, putting on an eye-popping shooting display.

Afflalo made his first seven three-point attempts, missed only three shots in the game and finished with a season-high 38 points to lead the Knicks to a 111-97 victory.

“I just wanted to be aggressive and bounce back,” Afflalo said. “But once I started feeling the shot going, I got to commend my teammates. They kept finding me in rhythm.”

Afflalo shot 14-for-17 from the field, including 7-for-8 from three-point range, in the first game of a home-and-home. The Knicks (16-19) will play in Atlanta Tuesday night looking to match their win total for all of last season.

Afflalo, who was only five points away from matching his career high of 43, said he’s been in this type of zone before.

“A couple of times,” he said. “Not in the past week and a half. I’ve had a few games where I was able to shoot the ball well from three.”

It’s been a rough few games for Afflalo, the Knicks’ No. 2 option behind Carmelo Anthony on many nights.

In the previous three games, Afflalo shot 8-for-28 — 1-for-8 from three-point range — and totaled 17 points. He had only four against the Bulls, which was a forgettable game for all of the Knicks.

Afflalo said he was personally motivated by his recent performances. “I want to play well,” he said. “I want to play well and I want to play well consistently. For me, consistency is more important than great games and very bad games. The more I can be counted on night in and night out, I think the better it is for the team.”

Robin Lopez had 16 points and 11 rebounds. Kristaps Porzingis added 14 points and Anthony had 11 points, nine rebounds and five assists.

The Knicks called this game a “must win” after the loss to the Bulls, in which they scored eight points in the final quarter, a franchise low for a fourth period. Against Atlanta (21-14), they played a complete game against one of the better teams in the Eastern Conference.

After the Chicago game, in which the Knicks fell behind 11-0 and were outscored by 23 points in the fourth quarter, Derek Fisher said they “gave in” and called their defense of late “horrendous.”

The Knicks responded by leading for most of Sunday’s game. Atlanta held a one-point lead for only 13 seconds in the first quarter. The Knicks led by 15 in the second, 17 in the third and 18 in the fourth.

“I thought the guys were just determined,” Fisher said. “Guys were professionals at the highest levels, and I think the way the game ended the other night in Chicago, they wanted to go ahead and erase those memories and create some new ones.”

No one more so than Afflalo.

“Arron’s a pro,” Fisher said. “He was just very determined to make sure that there wasn’t any confusion about his ability to get the job done.”