The suspect in a Philadelphia mass shooting last summer who had been deemed mentally incompetent is headed to trial after his lawyers told a judge he has been undergoing treatment and is prepared to move forward with the case.

Kimbrady Carriker, 41, is charged with five counts of murder, as well as attempted murder, aggravated assault and illegal gun possession in the apparently random shootings in early July in the working class neighborhood of Kingsessing.

FALLS TOWNSHIP SHOOTING VICTIM'S MOTHER CALLS SLAIN DAUGHTER A HERO: 'SHE MAY HAVE SAVED THEIR LIVES'

During a preliminary hearing Tuesday, detectives played footage from an officer's body-worn camera showing Carriker walking about a mile during most of the shootings on July 3. Assistant District Attorney Robert Wainwright said investigators are still trying to figure out what caused him to fire on some people and not others, The Philadelphia Inquirer reported.

Kimbrady Carriker mugshot

This booking photo shows suspected Philadelphia mass shooter Kimbrady Carriker. (Philadelphia Police Department via AP)

Officers "were running toward the danger without regard for their own safety, just trying to do everything they could to stop this man from killing more people," Wainwright said.

Carriker’s attorneys told the court their client is undergoing mental health treatment and is prepared to move forward with the case. The municipal court judge forwarded the charges to county court for trial.

Prosecutors have said Carriker left a will dated June 23 at his home and a roommate said he appeared agitated and had been wearing a tactical vest around the house in the days before the shooting that killed 20-year-old Lashyd Merritt, 29-year-old Dymire Stanton, 59-year-old Ralph Moralis, and 15-year-old DaJuan Brown.

A fifth shooting victim, Joseph Wamah, 31, was found shot to death a day earlier in Kingsessing.

A 2-year-old boy and a 13-year-old youth were wounded by gunfire and another 2-year-old boy and a woman were injured by shattered glass in the shootings.

CLICK HERE TO GET THE FOX NEWS APP

Philadelphia police have said Carriker was wearing a ski mask and carrying an AR-15-style rifle when he shot people and cars. When he surrendered in an alley, police found he had two guns, extra magazines and a bulletproof vest.