Search code examples
unity-game-enginesceneroguelike

Unity: How do I have distinct rooms without changing scenes


I'm trying to create a roguelike in the vein of Rogue Legacy, but I need to know how to not have enemies carry over from room to room. All enemies need to be idle and reset when you leave the room. I want to do this without changing the scene because that would be very memory intensive.

Here is an example: https://youtu.be/B5jL25HgSIs

Bonus points if you know how to lock cinemachine to the room that you are in.


Solution

  • Yeah, I wouldn't recommend changing the scene as that takes more time (and all the GameObject instantiations can be avoided).

    What I'd do is to have a single scene with all of my rooms, and determine in which room my character is by checking its position. If I detect it has moved to another room then I'd move the camera to render the next room, and in the same code I'd reset all the enemies of that room. At the same time I'd freeze all the enemies in the room I just moved from.

    By the way, I feel this question, more than pertaining to Stack Overflow, pertains to Unity Answers. That one is specialized in Unity while here I rarely see a Unity-related question.