Mr. Shaynak, an aerospace and physics teacher who still acted the part of a pilot in school — even wearing his old uniform there — was accused last week of abusing seven teenage girls over three years, of 36 charges including sexual abuse, forcible touching, kidnapping, endangering the welfare of a child and disseminating indecent material. Mr. Shaynak, who pleaded not guilty to the charges, is scheduled to next appear in State Supreme Court in Brooklyn on Nov. 25.

Interviews with dozens of people who knew him yielded few clues that Mr. Shaynak might be capable of this kind of predatory behavior. They painted a picture of a brilliant but flawed man, respected by almost all who knew him — at least when they knew him, before his students became his main social network. In high school, he had a leading role in the musical “Damn Yankees,” with a voice that “pulled many heart strings,” his yearbook said. He was the aviation student so good that his instructor asked him to help teach a “principles of flight instruction” course. He was the pilot so meticulous he would rather leave his job than cut any corners.

“I looked up to him,” a former high school classmate said, speaking on the condition of anonymity for fear of retaliation. “I remember thinking that he was very talented, just in general. I would have thought he’d gone to an Ivy League school. He was an exceptional student. I saw him as an exceptional person.”

But there were signs of trouble. He had a temper, once attacking an 11-year-old neighbor for throwing rocks, the neighbor’s family said. He was disciplined for berating a student in 2012. He courted instability. He did nothing to save his Maryland home from foreclosure. He ignored a landlord’s attempts to force him to pay long-overdue rent on his apartment in the Washington Heights section of Manhattan.

Image Mr. Shaynak Credit... Byron Smith

As a new teacher, Mr. Shaynak seemed conflicted about where to draw lines with students. He showed up to a high school party one year, and then told a student the next year that attending students’ parties was a bad idea, the student said. He told some students he could not be friends with them on Facebook until they graduated, but he made exceptions for others. Despite his apparent reservations, he rationalized going to students’ parties, saying he only wanted to listen to new music. He regularly smoked outside the school with students.