How to retain movement between levels?

So I’m making a 2d game and I have room transitions. I want the player to keep moving like in Hollow Knight, but since the rooms are different levels for performance, the player just stops.

My movement script is really just some bools:

I could just pass along the variables through either save files or the options string, but if the player releases the button during the loading screen then they’ll just keep walking afterwards(Or at least that’s my theory)

Can anyone think of anything or should i just switch to a door or something like in Castlevania?

Is the player separate from the levels? That would be the first thing I think :blush:

So you would have a ‘persistent’ level in which the player resides, and stream the other levels in. You can either do that with streaming volumes, and blueprints ( load level instance ), or even possibly World Partition.

Best thing to do would be put all the rooms in the same persistent level, and use level streaming to add sublevels with more rooms as needed. To constrain camera to a single room, create an actor class called bp_RoomVolume or some such and add a collision box to it set up to overlap all (orjust pawn) and tick triggers overlap events. Set box extents to match your room size, then in player, use on begin/end overlap events to get info from overlapped room volumes (either with an interface, or hard cast is fine since they’ll always be loaded anyway. If rooms don’t scroll, simply add an arrow component or something to bp_RoomVolume marking where camera should be locked to, get its world loc when player enters a room and use that to set camera loc . If some rooms can scroll left/right/up/down, do math on the trigger box extents in construction script of the room volume to determine min/max camera x and y (or x/y and z in world space) and use those values to clamp camera loc as it follows player.

This is basically how Bloodstained (IGA’s newest “Castlevania”) and Shadow Complex (an xbox360 MetroidVania made in UE4) did it.

One thing of note that I feel has yet to be mentioned is streaming levels can cause a lot of dependencies to load if they are all referenced from one individual place. I would suggest looking into soft references to ensure your loading practices are sound. In a game with fidelity like you have shown, performance and loading may not be that much of an issue but as your game grows larger and more complex, you would not want to load your entire game all at once from one singular level.

Well, I think this would mess with my save system as I have arrays of actors to be either destroyed or modified per level, initiated when the level is loaded, and constantly loading and unloading them would probably not allow that.

if you have a save system, just save the ‘velocity’ and apply it in the next room

I mentioned that in my first post. If the player releases the button during the moving screen, they’ll keep moving until they press it again.

Try adding the snaphotted velovity as an impulse on begin play in each level rather than just directly setting velocity. Then if player releases input during transitition, it should just nudge them as if they had tapped same direction key them on next level and standard movement comp braking will slow them down instead of just accepting the set velocity as gospel which must be obeyed until a wall stops them? Moving everything to a persistent level should be fine tho as long as all the saved things are serialized well. Lots of games autosave tons of stuff in the world as the player moves about. Might need to simplify how some things work. Like enemy spawners might need to just save a bool and a timestamp so its begin play (and save event) is faster.

thats why i said velocity, not the bool. I’m not sure how you’re designing it but i wouldnt even use a bool, you can use a float that goes between -1 and 1 and degrade it to 0 when no key is down for a slide/momentum effect

Thank you!

However, I made this room transition inspired by the 2d Metroid games and I actually think it works better, but still, thanks for the advice.