ATLANTIC CITY — A judge has dismissed a lawsuit filed by the family of a Pennsylvania man who died when the sand under his feet collapsed as he walked along the shoreline, plunging him into the swirling waters of an inlet.

Superior Court Judge John Porto dismissed the lawsuit Tuesday brought by the family of Brad Smith of Horsham. He died in July 2012. The family sued the City of North Wildwood and the state.

The judge cited state law granting immunity to governments from injuries occurring on unimproved public property, or land that is in its natural condition. He ruled that conditions at the Hereford Inlet in North Wildwood were naturally occurring.

Two other people died in a nearly identical manner three years earlier, but they were not part of the lawsuit.

"This was a very tragic set of facts," the judge said. "That's not overlooked by the court."

But he ruled that New Jersey legislators were clear when they enacted a law governing suits against public entities that governments cannot be sued for injuries sustained on land that, while owned by a town or state, has not been altered by those governments.

Porto ruled that the inlet, by definition, is constantly shaped and reshaped by wind, currents, and tides. Man-made improvements located 400 feet to 600 feet from the water’s edge, including a seawall, did nothing to alter conditions along the inlet’s edge or cause a dangerous condition that did not exist before, he said.

Smith was walking in ankle-deep water at the beach with his daughter when the sand collapsed, plunging them and a friend into the inlet’s waters. A passerby on a personal watercraft rescued the girl, who was being held above the waves by her father before he drowned.

Three years earlier, Jamila Watkins, 27, and Shayne Hart, 15, were walking along the water’s edge when the sand gave way beneath them, killing them both.

Paul D’Amato, a lawyer for Smith’s family, presented pretrial statements from North Wildwood Beach Patrol officers who said they knew potentially dangerous conditions existed at that spot along the inlet, and that similar tragedies were likely to happen again.

"We started this case so that no other family would have to go through what they did," D'Amato said afterward. "It's just an incredibly sad day."

He said the Smith family would appeal the dismissal.