Classic Resident Evil-style room loading/level streaming?

Hi all,

I was wondering how one would go about implementing level streaming/room loading as in the classical Resident Evils (0, REmake, 1, 2, 3)

As most of you probably know, in RE if you’re in a room then you’re pretty much in isolation from actors/entities/objects in other rooms, so a zombie can’t break in and attack. It’s like there’s a separate memory space for each room.

My guess is that when a player enters a room, they load the room with whatever tickable objects in it (zombies etc) and the background renders. When you exit the room, they check if the room should save anything (*), unload it and load the new room.

(*) Take for example the pictures with the crows room in RE1 (@24:15), if you mess up the puzzle and exit the room and re-enter, the puzzle would reset, but if you solve it correctly then exit/re-enter the puzzle had already been solved. I’d imagine there’s a save that’s done to the room upon player exit if the player solves the puzzle, and a load when the player enters.

I would like to achieve a very similar thing. I know that they probably couldn’t load more due to hardware limitations, but most of the times I find myself seeking ways to achieve the results/outcomes of those limitations (Most the times those limitations end up playing a major role in enhancing the overall experience of the game they were implemented in (the fog in Silent Hill 1, the static backgrounds/cameras in RE etc)). I was wondering how one would go about implementing that in Unity. I thought about two approaches, but before I talk about them let me mention some of the prerequisites I want to meet in this system:

  1. Each room is isolated, enemies in other rooms have no way of interacting with you/breaking in.
  2. Fast loading times when entering rooms (I usually play the PC version of RE3 just because I can skip the door loading scenes…)
  3. The ability to save room state upon exit if necessary (this is a room-dependent thing)

My thoughts/approaches (just theory, haven’t tried them in practice yet):

A) Use a separate Unity Scene for each room.

Pros:

  1. It easily ensures the room’s isolation.
  2. For saving/loading, I could keep track of the current loaded scene and use some of Unity’s callbacks like OnLevelWasLoaded or OnDestroy/OnDisable & Awake/OnEnable in a per-scene manager behaviour.

Cons?

  1. I’m not sure about loading times, I’m kinda worried that some rooms will have longer loading times than others…

  2. There’s gonna be a lot of small rooms, it could be an overkill to use a separate scene for each of them…

  3. More scenes = more management + extra care needs to be taken cause from my experience scenes are fragile and could corrupt pretty easily which means I should not rely a lot on the editor to set my things up and go data-driven (which I’m already doing) and do the least amount of config to re-setup the scene if necessary.

B) Load a relatively big rooms chunk, e.g if I had a two story building, and the player’s in the first floor, I’d load all the rooms in that floor - they’re all in one scene. When player goes to the ground floor, I’d load the whole ground floor. Take for example the room in this video (the bg is pre-rendered btw :p) - I’d load it and all the rooms in it in one scene. But then to achieve room isolation I’d have to come up with a system that, for instance give each room an id, and keeps track of which room the player’s currently in and deactivates all objects in the other rooms (I imagine the whole room would go under a GameObject for organization purposes and to make it easy to disable/enable rooms?) - Saving/loading wise, not much of a change. I’d still have to save/load things when player exits/enters a room or changes scene.

Here’s an old map of that floor:

Pros:

  1. Less scene management you could argue.
  2. Faster loading times when traveling between rooms since they’re already loaded.

Cons:

  1. Room isolation is not as perfect. There could potentially be bugs where entities in other rooms might remain active, or don’t initialize properly or Idk… But I don’t think it’s a huge deal I just haven’t tried it yet…
  2. Larger scene = harder to reconfigure/rewire if it gets corrupt.

My questions:

  1. Are those two approaches decent? Which do you think is best and why?
  2. A lot of the times we’re in a tunneled vision and can’t see outside of it, that’s why we ask for others’ opinions/thoughts: do you see something I don’t in those two approaches? (in particular: potential bites, gotchas and caveats)
  3. Can you think of a better approach?

Those were my 2 cents, can’t wait to hear yours!

Thanks in advance for any help/ideas!

EDIT More on approach B: maybe each room would be a prefab?

It’s like there’s a separate memory
space for each room.

It’s a little more straightforward than that. To borrow a note from the Wikipedia entry on the original Playstation:

RAM: 2 MB main, 1 MB video

There wasn’t enough RAM in the system to hold any significant amount of 3D model and texture data in memory simultaneously. The rooms would’ve been loaded and unloaded in order for the game to function whatsoever, with as little overhead left over as possible.

As far as creating a representation of that system, however, you could create a Room class to hold data regarding the room’s contents, their default state (if needed, such as puzzle rooms), their current state (enemy positions, if applicable), entrances/exits and more.

The player would then be able to transfer between “Rooms” and all the data from the room you’re already in would be left behind. To actually process contents of a Room, define which objects can move without the player present (again, enemies?), then tell everything else to be immobilized. Why do that? Well, modern hardware is a bit powerful than a Playstation[citation needed][1]. You can define regions in each Room that tell your computer to load data for the adjacent Room you’re approaching. Then, your rooms can connect seamlessly (and, if a room’s not loaded yet for any reason, put the player in limbo until the room loads or, if it times out, send them back to where they just were when they tried to enter).

On the other hand, if you would prefer to change scenes for each Room you would use, you can make use of Application.LoadLevelAsync() to ready the scene ahead of time instead.

Edit: Yeah, my first portion of this does basically suggest using prefabs and loading them in on demand if you’re going for lesser memory/video usage at a time.

In our project we use the SECTR plugin to manage streaming chunks of levels.

Nathan, the creator is very helpful in supporting, and has added various features to the plugin to accommodate our project.

Well I’ve gone with the scene per-room approach, seems good enough. Loading times are good, Unity 5 improved scene loading. I save selectively marked objects in the room to disk on exit, and load them on enter.

Can someone please show me how to do this??

@vexe