Hello! I am working on trying to make sure my character does not fall through the ground on gameplay.
I am using World Composition and am trying to figure out if there is a way to get the current streamed level a player is in?
I am planning on using it to pre load that level when the level is loaded, then after that is complete it will set the players gravity scale back to 1 to allow them to fall to the ground.
Just to clarify, I already can already detect when a streaming level is loaded, I am just trying to get the players current streamed level.
This is currently an all Blueprint project.
Any help is appreciated! Thanks!
Are you spawning the player? If so, spawning places actors in the persistent level.
I’m using Player Start locations for initial spawning player. Spawning works fine, but what I am trying to do is get what the current “sublevel” the player is in so after it is loaded I can then enable gravity and input for the player. In other words I’m trying to get what level the ground beneath the player is.
Example: My player spawns, and they are in “sublevel” 11, then if they move in any direction far enough they will move into a new level streaming bounds, which means they are no longer in “sublevel” 11 they might be in 18 or 20 or 2 etc. I can get it so sublevel 11 is loaded, then the player has gravity and input switched on. The problem is I can only specifically tell it to load one sublevel. So if the character moves to sublevel 20, saves the game, then restarts, they will fall through the floor because sublevel 11 is still being preloaded and not sublevel 20. I’m just trying to see if there is an easy way to get the players “sublevel”
Note: sublevel is probably more properly defined as all the levels that are within my persistent world, which were brought in as a tiled landscape.
I may try just setting a box with on overlap and assign a variable with the sublevel name in it, then pass that to my “preload” logic. But I feel like UE should have a built in function for this, no?
Ok, you can’t do it. When you spawn a player, they are spawned in the persistent level, so there’s no way of finding them in another level.
The only thing you can do is look at the player XY coordinates and compare them with your level maps to find out which terrain they are nearest to.
Why not put the level name and the player position in the savegame. That way, when you restart, you know which level to load and where to put the player.