Not so far in the future, your doctor might prescribe playing a few games in virtual reality to ease aches and pains, rather than popping a pill.

That’s Matthew Stoudt’s hope, anyway. He’s the CEO of AppliedVR, a startup that’s building a library of virtual-reality content for alleviating pain and anxiety before, during, and after medical procedures. The company is working with hospitals and doctors to get patients using the technology on Samsung’s Gear VR headset and to study its effectiveness as well.

So far, the company has created three different virtual-reality pain applications, as well as one for reducing anxiety, Stoudt says, and it’s using some third-party content, too. Headsets running AppliedVR’s platform are being used in hospitals, doctors’ offices, and clinics for things like drawing blood and administering epidurals, as well as for pain management after operations.

Illustration by Niv Bavarsky

Virtual reality has long been studied for its potential to ease pain by serving as a distracting force during medical procedures like wound care sessions for burn victims. Yet typically the equipment needed to bring virtual reality into hospitals (or anywhere else, for that matter) has been extremely pricey: Hunter Hoffman, director of the virtual reality research center at the University of Washington’s Human Photonics Laboratory and a developer of a pain control game called SnowWorld, says the VR equipment he’s using as part of an intensive care unit pain-relief study costs $35,000.

With cheaper headsets like Samsung’s Gear VR, Oculus’s Rift, and HTC’s Vive now on the market, though, it’s a lot easier for hospitals and doctors to consider using them for their patients, and a number of startups including AppliedVR see a business opportunity. AppliedVR sells its service—the VR content plus a Gear VR headset— to customers for far more than the $100 you’d pay for a Gear VR plus the price of a compatible high-end Samsung smartphone, but still much less than virtual-reality devices have cost in the past. It declined to disclose the exact pricing.

AppliedVR is working with Cedars-Sinai Medical Center—an investor in the company—and Children’s Hospital Los Angeles, which are conducting studies using its software. One study that Cedars-Sinai recently completed but hasn’t yet published had a group of 60 patients with a range of medical conditions (things like abdominal pain from pancreatitis or chest pain from pneumonia) use AppliedVR-provided content including a game called Bear Blast, in which the player moves his head to throw balls at cartoon bears.

The game, which I tried out in my office, is pretty simple and seems purposely mesmerizing: you constantly move forward at a slow pace through a virtual world filled with bears and lob balls at as many of them as possible to earn points. Unlike most games, you can’t get hurt or die.

Brennan Spiegel, who directs health services research at Cedars-Sinai, says researchers found that 20 minutes with the virtual-reality software reduced patients’ pain by 24 percent on average; before using VR the patients had a mean pain score of roughly 5.5 on a zero to 10 scale, he says, and afterward it averaged 4.

“That’s a pretty dramatic reduction for an acute pain,” he says. “It’s not too different from what we see from giving narcotics.”

Now, Spiegel says, Cedars-Sinai is going to conduct a controlled trial where some patients get virtual-reality headsets that they can use whenever they want during their hospital stay and others don’t.

Spiegel is cautiously optimistic about virtual reality’s prospects for helping reduce patients’ discomfort. He thinks the technology could be beneficial to people who are in pain or, at the least, could use some help with relaxation, both in the hospital and after they go home. But, he says, it won’t help everyone, and a lot more data has to be gathered before it will be clear if it’s truly useful.

Elliot Krane, chief of pediatric pain management at Stanford Children’s Health, also thinks VR’s power for distracting could be valuable for, say, helping kids with physical therapy and getting them to stay still during imaging studies. To him, the biggest challenge right now is finding software developers who want to make applications that target specific medical problems—something AppliedVR says it wants to do to grow its catalog of content.

Spiegel points out that it’s also important to figure out when the technology can be helpful and when it isn’t the right approach. He remembers trying to convince a patient whose cancer had spread that she could put on a headset and be transported, virtually, to Iceland; she looked at him like he was crazy, he says.

“We have to be careful about not overselling virtual reality, or any other digital technology,” he says.

Update: This story was revised from its original version with additional information about pricing from AppliedVR.