In "The 13th Floor" person A experiences a simulation of person B's body and world. If person B dies while person A is experiencing their world, person A's sense of self is destroyed and person B then takes their place and wakes up in person A's body. This can happen on as many levels as possible in terms of simulations within simulations. In "The 13th Floor" what happened was person A (physical world) took host of person B from time to time. Person B was taking host of person C from time to time. Person B realizes he is inside a simulation himself and is killed while being hosted by person A but wakes up as person A in the real world.
I never understood the explanation for that. When you think of the brain it is comprised of trillions of organic connections that are created over a substantial period of time. They are not able to be rearranged in a sudden blink of time. It seems absurd in this case to believe a plausible technology of virtual reality and recursion then to be suddenly jarred into "magic" to have to believe a sudden "soul" is replaced. Why would someone design a system to do that? If you have a good explanation for that, please let me know.