The avatars are then switched and so the patient is portrayed as the child and hears their own advice repeated back to them.
The project, part of an ongoing study at University College London, is the first time that such technology has been used on mental health patients, according to the BBC.
A trial was said to have helped nine of 15 NHS patients aged between 23-61, four of whom reported “a clinically significant drop in depression severity” after three 45-minute sessions.
Prof Chris Brewin, lead author of the study, said the results were promising and patients had described the experience as “very powerful”.
He said he believed the effects of the treatment could last for up to a month.
“People who struggle with anxiety and depression can be excessively self-critical when things go wrong in their lives,” he told the BBC.
“In this study, by comforting the child and then hearing their own words back, patients are indirectly giving themselves compassion. The aim was to teach patients to be more compassionate towards themselves and less self-critical.”
The treatment first requires the patient to wear a headset that projects a life-sized image of themselves through a virtual reality mirror.
They are asked to identify with the avatar, which replicates their movements in a process known as “embodiment” before the image of a small crying child appears alongside them.
When told to try and comfort and console the child, patients reportedly asked them to think of a time when it was happy and to think of someone who loved them.
The roles were then reversed and the patient was embodied into the avatar of the child before hearing the same advice repeated back to them in their own voice.