Former NBA star Ben Gordon opened up about his suicidal thoughts and struggling with bipolar disorder in a Players Tribune essay published Thursday.

"There was a point in time when I thought about killing myself every single day for about six weeks," Gordon said, referencing an identity crisis after his NBA career ended. "I would be up on the roof of my apartment building at four o’ clock in the morning, just pacing to the edge of the ledge, looking over — pacing back and forth, back and forth — just thinking, I’m really about to do it, B. I’m about to escape from all this (expletive)."

Gordon said he contemplated and attempted suicide several times, describing one ordeal: "You become like an animal. It’s instinctive. Escape, escape, escape, escape. I took one of those heavyweight jump ropes — the thick rubber ones — and I tied it around my neck. Got a chair. And I hung myself, for real."

Gordon said he realized then he wanted to live. In the essay he also opened up about his panic attacks, comparing the anxiety to a "black cloak" that was "suffocating" his "soul." He said he felt emotionally "stuck somewhere between heaven and hell" before he started seeing a therapist.

"Mental illness touches everybody," he wrote. "Every community, every person. Either you or somebody you love is going to be touched by it at some point."

The 36-year-old has had run-ins with the law. In June 2017 he was arrested for pulling fire alarms at his Los Angeles apartment building. Later that same year, he was hospitalized for a psychiatric evaluation after an altercation at a holistic wellness center in Mount Vernon, New York.

"The only thing that saved me was getting arrested, as weird as that sounds," he said. "I got arrested four times in five months. I was out of my mind. So the judge hit me with court-mandated therapy — 18 months."

Gordon was the No. 3 pick in the 2004 NBA draft after propelling the UConn Huskies to a national championship the same year. He won the NBA's Sixth Man of the Year award in his rookie year with the Chicago Bulls. In his 11-year career, Gordon played for the Bulls, Detroit Pistons, Charlotte Bobcats and Orlando Magic.

Gordon said he wrote the essay to encourage other athletes to seek help.

"I know for athletes especially, that might sound soft," he wrote. "We’re trained to think that way. It’s almost like we’re brainwashed. But the whole reason I’m telling you my story is because I know — I know — there’s players out there who need help."