A homeless man who entered a Denny's restaurant at lunch time muttering and looking dazed opened fire, gunning down two people, wounding a couple and then turning the gun on himself, police said.

The gunman, holding a semiautomatic handgun in one hand and a revolver in the other, entered the restaurant Wednesday and began shooting within a few steps of the front door, sending patrons and workers fleeing to the restaurant's bathrooms and kitchen.

The dead were identified as Frank Velasquez, 65, of Oceano, who was killed in front of his wife and 5-year-old great-granddaughter, and Harold Hatley, 73, of Grover Beach.

"They were just enjoying an innocent meal," Police Chief Joe Cortez said of the victims.

The gunman, identified as 60-year-old Lawrence Edward Woods, also wounded a married couple before fatally shooting himself in the head, police said.

Authorities were trying to determine whether Woods had a history of mental illness or whether there were drugs or alcohol in his system, Cortez said.

The gunman didn't appear to have a grudge against the Denny's chain or the specific restaurant off Highway 101 in this small town known for its beaches and clams. Cortez said Woods may have had an "economic motive" for the shootings.

Velasquez's wife, LaVina, told her son the gunman said "it's all Mid-State Bank's fault," the Los Angeles Times reported.

Cortez and a hospital spokeswoman declined to identify the injured couple, both 58, who were released from a hospital after being treated for gunshot wounds.

Denny's said Wednesday it was cooperating with police.

"We are shocked and saddened by this tragic incident," the Spartanburg, S.C.,-based restaurant chain said in a statement. "This appears to be a random act of violence."