There is an area of the brain (the cingulate cortex for you neuro-geeks) that is partly concerned with how much attention is given to experiencing a particular pain. It has been found that the use of virtual reality is so stimulating, that it leaves less attention available to tune in to the pain… hence we don’t feel it as much. In this particular research, burn victims found relief by immersing themselves in cooling virtual environment.
You see, pain is all in the mind. Once the pain signal is sent to the brain, what we experience and how intensely we experience it is all a matter of how the brain interprets it. This is why when you touch something hot or very cold, for a split second you can’t tell the difference. This is also why we don’t notice a pain when we are very occupied. (ever notice a bruise later and not have any idea how you got it).