Trying to create smooth room spawning for an Endless Runner style game

Hey All, I’m working on an endless runner game, where you travel from room to room (infintiely)
As you get to the end of the room it should spawn/load/create the next room.
I’ve tried creating a room spawning blueprint that spawns with floor,ceiling,walls,some random decor and occasionally a few characters. I’ve also tried creating each room as a level with level streaming.
I keep getting an issue where certain rooms ( beyond the most simple walls,ceilings,floors), give a stutter or significant frame drop in the game on spawn/levelload. (running on android)

Does anyone have an idea as to how best to spawn/load a room smoothly. And also clear away the rooms as you leave?
Thanks in advance for any advice. :slight_smile:

@paynter3D Very hard to tell without seeing the actual setup, but I would say an easy way to kill the rooms is to do it on distance from player. Otherwise it becomes a bit of a nightmare trying to figure out when to remove them. Just have each room BP watching distance to player on a timer event, when it gets too high, bang, destroy actor.

Thanks for the reply @ClockworkOcean . I did try a distance from player at one point, then changed to a trigger outside the room actor that destroys the room. Both worked well. However the main hurdle I am trying to overcome is smoothly spawning/loading/creating the next room without a significant frame drop.Since my character is basically running from room to room there is a noticeable “freeze” when I try to spawn or load a room that is anything other then an empty box.

@paynter3D That does sound a bit like the spawn is quite heavy. What do you think is causing that?

Instead of spawning a new room every time the player reaches the end of the previous room you can reuse an existing room. Almost like an escalator, as a player leaves a room and it’s now behind the player and is no longer visible you move that room to be in front of the player as an upcoming room. You could have a function on your room actor which randomises the appearance which you would call too so you can still get random looking rooms without spawning new rooms and destroying old rooms.

If i spawn an empty room with a few actors (like an obstacle or something) it works fine. I’m trying to create more interesting and unique rooms, so that’s where my frame hit is coming from.

In one of my problem rooms [an arcade] I was trying to use a blueprint inside the room spawning blueprint that spawns about 20 (simple) arcade machines. (I was trying to make it so when that room type spawns, it’s somewhat random). So that method doesn’t look like it’s going to cut it for me, unless there is some trick to it that could make it more efficient.

I have another room that has several tables and chairs placed into the child room blueprint, and that also has a small frame drop on creation (but if the very next room is the same type, it works fine)

@hendore I’ll play around with your suggestion when Im back in town. Seems like that could work if all the main room types are preloaded in, and I just move and alter looks of room?

Maybe solution is to put collision box on each room. On overlap you can spawn/destroy specific room (overlap at begging and the end of the room). About “freeze” I think problem is loading textures. Try to load all textures that you are using dynamically on begin game ( “invisible” loading textures ) - lazy load.
I used this trick for similiar mobile game (endless runner) and it solved the problem - no more “micro freezing” and everything is smooth.