A man who prosecutors say is behind a string of brutal attacks on people on the streets of San Diego in 2016, many on homeless people, was in court Monday to begin what was expected to be a lengthy preliminary hearing.

Jon David Guerrero was found mentally competent to stand trial on four murder charges, three attempted or premeditated murder charges, two arson charges and five assault charges in June 2019, three years after attacks on a dozen people over a six-month period.

Homicide investigators say that in some incidents, the attacker used a railroad spike to impale his victims. Some victims were set on fire.

The preliminary hearing is set to determine whether Guerrero should face the death penalty if he is convicted.

One of the last people to be attacked in connection with the series, Mike Papadelis, was the first witness to take the stand during Monday's hearing.

Papadelis told the courtroom he was left with a crushed eye socket, a broken nose and jaw and is nearly blind because of the attack while he was sleeping near 18th and C streets on July 15, 2016.

"I'm lucky to be alive because the [railroad] spike was there and I was asleep. He could have put it right through my head, or my chest, or my neck but I don't know. I guess it just wasn't my time," Papdelis told NBC 7.

He recalled being struck once and awaking to eyes looking at him. He was then struck several other times before it ended, possibly because he blacked out.

The defense attorney questioned how Papdelis could know it was Guerrero in the dark and while he was sleeping.

Investigators believe Guerrero is connected to attacks that began in July 2016, when 53-year-old Angelo de Nardo was found dead and badly burned near train tracks in Bay Ho.

At least one of the attack victims was not homeless; 83-year-old Molly Simons was found beaten on July 13 near Arizona Street and University Avenue as she was walking to a nearby bus stop to volunteer at a local YMCA, according to her autopsy report. She died two weeks later.

On July 4, two homeless men were discovered attacked within an hour of each other in Bay Ho and Ocean Beach in the early morning hours. One of the victims, 41-year-old Shawn Longley, died from the vicious assault.

On July 6, 23-year-old Derek Vahidy was found attacked and lit on fire in Pantoja Park near State and G Streets. He later died in the hospital.

Guerrero was arrested on July 15 after a fifth man, Papadelis, was attacked at 18th and C streets and has been in custody since.

He was sent to Patton State Hospital for treatment after he was found not competent to stand trial in July 2017.