Character Switching With World Partition Enabled in a Single level

I have 3 characters in my level and I want to switch between them in a single player game like GTA V. The issue is the character switching is only possible when the other characters are present in the level and with world partition on, the other characters are getting unloaded and breaking the character switching mechanism.

Is there a way to get around this?

I intend to stream the area of all the 3 characters simultaneously but I have no idea how to do that.

Any help is appreciated.

Hey @CyKrome! Soooo there’s an inherent problem with your example, you see. In GTA V when you switch characters, you know how you zoom out really far and then go to the switched character’s location? They have something like a large set of “What could they be doing while offscreen” variables, and then when you switch they load that in. The character, their environment, everything is loaded on the fly when that button is pressed, as far as I know. Because keeping the environment loaded for three separate locations in such a busy game… Graphics and processor-wise, that’s literally like running the game three times on the same system simultaneously but only getting to play one.

Unless you really have a very important game mechanic to use… I suggest saving necessary data before the switch, let the character and environment get unloaded as you switch. Then when you switch back to them load their data you had saved.

I want to know how to load all that data in the game. One way I can think of is storing the last known location of Other 2 Characters. But at begin play we don’t have any information about the last known location of the Other Characters.

What THEY did was use a pool of random locations in the city for each character.

What that means for you is: You need to save their location when you switch out. But it also means that same variable needs to be set by default to a location that you wish for them to start, so that it doesn’t default to 0.0.0. If their house is at 356,42,558, you set that to be the “Default value” of your “Saved position,” so that’d be their “New Game” spot.

Does that make sense?

Thank You Very Much… I also want to know is exactly what should I do to load the sub-level of that area during switch assuming I have a vector location to switch to…

You can do it through an event, just use these nodes and make sure to set the “Level to Stream” Name variable to the exact name of the level chunk you’re in!

I strongly suggest you read and memorize the documentation for level streaming, as it’ll be a big part of your game! :slight_smile:

This documentation is about loading another level. What I want to do is load a location in the current level if not already loaded and spawn the switched character there. Is it possible?

What I want to do is something like this. Is it preferable? If yes then how to do it…

The link is specifically about level streaming… and your title was too… It’s about loading things and unloading them in “Chunks”. If you want to use one big level it shouldn’t be an issue because what isn’t loaded is just visual. The collision and everything should be there.

I’m Really sorry… it’s a novice mistake. I have World Partition Turned on in the level. So, the characters in the unloaded region aren’t present in the game while playing. Hence, I’m unable to switch them.

What should I do in this case?

I suggest making a “Manager”. An empty actor that each character has registered as a reference. Then when you want to switch characters, use a dispatcher to run an event on that manager to spawn the new character and switch to it, at the location that was saved. (Which, by the way, can be saved on this manager as well! So that way when the character is destroyed by the switch the data is saved.)

Thank you very much