Ten hours before Tevita Filo killed a woman jogging in Remuera, police pulled him over and found a knife in his car - and gave him a warning.
On 7 January, he killed Joanne Pert as she jogged in the upmarket Auckland suburb.
Justice Gilbert, in the High Court in Auckland, today found Mr Filo not guilty by reason of insanity. Mr Filo thought he was in a computer game, the court was told.
Ms Pert's family said Mr Filo had left a "huge hole in our lives".
Her parents, Kevin and Jan Pert, said in a statement they had sleepless nights and would never forgive him.
"When we do finally sleep we end up waking in a cold sweat, wondering about the last moments of our much loved daughter's life.
"Mr Filo has left us angry and unable to forgive him for this heinous crime."
Mr Filo faced 15 charges, including murder, over the January killing and indecent assaults around the same time.
Ms Pert, a 41-year-old mother of two, was found dead outside a house on Shore Road in Remuera. She did not know Mr Filo.
Outside court, Detective Inspector Kevin Hooper said police stopped Mr Filo after he followed a couple in his car just 10 hours before he killed Ms Pert. They found a knife in his car.
"Based on their assessment of the situation, the officers used their discretion and issued a roadside warning."
Mr Hooper said he said he was satisfied that their use of discretion was warranted.
"I can say that it's common practice throughout New Zealand for officers to use their discretion when dealing with roadside stops and from a police perspective, we encourage staff to use their discretion."
Mr Hooper said police had no record of Mr Filo's mental health issues and there was no evidence he received any treatment in the lead-up to the killing.
After killing Ms Pert, Mr Filo went to Auckland Hospital where he indecently assaulted a woman.
He indecently assaulted a third woman at a bus stop before handing himself in to police.
The court was told Mr Filo had suffered from hallucinations for five years.
There was evidence he randomly approached other people in the community in the days leading up to the killing.
Killer thought he was in a game
The court was told Mr Filo believed he lived in an alternative reality controlled by computers and came from another world where he was a powerful king.
Dr Mhairi Duff interviewed him four times and watched his recorded interview with police. She said that Mr Filo suffered from schizophrenia.
"His particular type of delusional belief system involves a complex altered world, in which the world .. .the rest of us are living is actually an altered reality.
"The players within this altered reality are controlled by computer controllers from a real world, from which Mr Filo has been temporarily banished whilst he has to complete some actions, missions, or tasks within this virtual world that the rest of us would call the real world."
She said the 25-year-old heard voices that commented on what he did, what he should say and what he should do next.
"He continued to believe that the person who he had killed was not a live human being, but rather that they were a computer-animated, controlled, artificial being."
Mr Filo told the doctor that by committing the crime, he believed he would end the game.
She concluded Mr Filo had no way of knowing right from wrong and that there was no way he was faking it.
Auckland Crown solicitor Brian Dickey said Ms Pert's family, many of whom attended court today, had grappled with the legislation around mental health, but were left angry and unable to forgive.
"The horrendous death of their most beautiful and most talented, highly intellectual, much-loved sister and wonderful mother of two beautiful children has left an open wound in their hearts which will never heal over and every minute and hour of every day, Jo is in their hearts."
Justice Gilbert said: "There is no doubt that Mr Filo tragically killed Ms Pert in a sudden and completely unprovoked attack."
The judge remanded Mr Filo in the care of a secure mental health unit so he could get continued treatment and to protect the community.
Full statement from Kevin and Jan Pert, the parents of Joanne Pert
"Mr Filo's unforgivable selfish action has left us with a huge hole in our lives, sleepless nights and when we do finally sleep we end up waking in a cold sweat, wondering about the last moments of our much loved daughter's life.
"Mr Filo has left us angry and unable to forgive him for this heinous crime.
"The horrendous death of our most beautiful, most talented, highly intellectual, much loved sister, wonderful mother of two beautiful children has left an open wound in our hearts which will never heal over.
"Every minute, every hour, every day, Jo is in our hearts."