Room Teleportation Issue

Hi,

I am currently working on a game mechanic that involves moving a room in a building temporarily when the player enters it. This room would be one of a number of rooms in a building and linked to the other rooms by a hallway. So let’s say room A is across the hall from room B and room C is across the hall from room D. There are no load screens when entering and exiting a room. When the player enters room A for the first time, the door closes behind them and room A needs to change location so that it is where room C is and therefore when the player opens the room door to exit, they should see room D across the hall instead of room B. When the player fully leaves room A and turns around, they will now see room C behind them and room A will be back in its previous location. The problem is that when placing a room in a level, usually walls and floors should static and it can be inefficient to move them at runtime. BTW, this event will only happen the first time the player enters and leaves room A.

My solution: Create a duplicate of the building in the editor but change it so room A is where room C was and place the duplicate at a location that is inaccessible by the player and that will not intersect the camera’s frustum so will be culled by the renderer when the player is not in the duplicate building. When the player enters room A for the first time, the door closes from behind and the player is spawned in the exact location in room A that the player is in but in the duplicate building. Now when the player opens the door in room A, they will see the duplicate room D across the hall and when they step out into the hall, they are teleported back to the original building outside of room C.

If there is a better way of doing this, let me know. I posted this in the C++ section because I am a C++ programmer and would prefer a more dynamic solution in C++.

Thanks in advance for any help.

Have you thought about having a camera looking through each door, then rendering to texture the scene through the door onto the hole of your door.
Then when the player touches the surface alter their location to the doorway they looked like they walked through.

I did a similar thing with an ‘endless corridor’ where the player looked through an arch and stepped into the same room they left, and could see themselves leaving.