PALO ALTO, Calif.—Software worker Erin Bell inched across a wooden plank suspended over a deep, rusted pit. When a Stanford University researcher asked her to step off, she wouldn’t do it.

In reality Ms. Bell was walking on a carpet with a virtual-reality headset strapped to her face. “I knew I was in a virtual environment,” she said later, “but I was still afraid.”

The...