Advice on aligning streamed levels?

Hey all I’m having some troubles aligning my load/unload streamed levels.

I have the base persistent level with all the other levels in their.

At start the base level is loaded in as well as another level by the exit. But when the level is loaded in it just goes to 0,0,0. I have an exit point and entrance point bp. WIth all the level’s geometry parented to the entrance.

I use a bp interface to pass along the transform of the abse levels exit point transform but for some reason even passing that along and setting the streamed levels entrance point to it, it will still not work.

Does anyone know of a simple way to just connect two actors from two different levels. That’s essentially what I’m trying to do.

  1. Spawn level(with exit points)
  2. Spawn another level
  3. Move 2’s entrance to 1’s exit(this fails)
  4. Repeat.

Did you try it as a level instance? Then you can specify spawn location.


Whether you use interfaces or not is a separate thing :slight_smile:

Hmm would that necessitate interfaces anymore? I just learned about them a bit ago and don’t really understand them.

But I will try this and update you. Thanks!

Appreciate it, it seems to work but I am out of time and need to go to work now, I think I can figure out the next part. But it starts and then compounds.

Like room 1 has 4 exits and 1 entrance. The script will run for every exit, and then the next room does the same thing.

You can always use the game instance as a sort of global variable repository :slight_smile:

You would need to manage which level was using which variables etc yourself.

Hmm after messing with it for a while it seems my problem is how do I bring variables from the last streamed level to the next one?

There isn’t a way to carry that info over that I can see so I can’t setup specific variables that are dependent on the last level if that makes sense.

My levels have a bp actor that sets up their entrances and exits relative to what level geometry is created. So I need to carry the location of those randomly generated exits/entrances to the next levels so they know where to align.

So persistent would have things like world seed and what level to generate next.

The next level would then carry that seed, it’s specific variables and the next level to generate to the next one and so on and stuff.

Is there a way to load a level and get instances of specific actors only within that level; ignoring the previous and persistent?

Do you know how would I be able to add unique actor refs to it though?

My room actor doesn’t have a lot going on but when I spawn the next level I can’t tell them apart and what happens is I just add the same one again, the next one repeat and then it does it again since get all actor of class doesn’t differentiate between streamed or persistant?

Sounds like the best way is to give the room actor an ID. That way you know exactly which is which.

You can use actor references with the game instance, of course, but an actor reference is not valid after a level has been unloaded.

Sorry, it’s also probably me missing the point slightly. What is IN one of these levels, can you do a pic?

Some thoughts:

  1. You could hard code the level name into the room actor, that way you will know which room you’re talking to.

  2. I’m assuming the rooms are centred on 0,0,0 in their respective levels, so all you have to do is load the level instance in the right place and things will line up.

  3. At the moment, they’re simple enough to be just blueprints, you don’t need streaming. That might change, depending on complexity.

EDIT: also, when room A loads another level ( containing room B ), it can then set an ID on the room in the level it’s just loaded. Then it knows which room is which.

EDIT2: Is there a randomization process occurring here? If not, then you can just use level streaming volumes.

  1. No. The actor contains variables, right? You can make one of them an ID or name. You can set this variable when you make the original level, before you add it to the persistent.

  2. This ( part of my game, but not my vid )

is a procedural maze. The clip here loads about 3-5 sections. It’s all blueprint, no streaming.

  1. Stop thinking about levels, and think about the actors. You can set an ID on an actor blueprint.

Any ideas?..

PS: The next part of the vid is also randomly loading blueprints, no streaming.

What I’m trying to say is, you can do it with streaming or blueprint. But if you use streaming, I don’t think you can get any handle on which actor is in which level. You need a system that only looks at the actors.

Something you could do is stream a new level. Then, the new actor will be the only actor without an ID. You can find it that way, and give it an ID, and then stream again, etc.

Addendum: apparently ‘getallactorsofclass’ only gets it’s own level actors if it’s done from the sub-level blueprint.

But how do I reference it? The persistent has the same actor and every new spawned level will as well, that’s the crux of my issue I can’t figure out how to differentiate between them to get a ref.

Can’t use get all of class, there is no way of locking that to a certain level?

There is no cast to specific level to get it’s actors nothing that can get that info.

I think the easiest way to differentiate them would be to get the level name and just add it as a tag then for loop through to compare the current level to the tag but I don’t know how to initially get the room actor ref.

Thanks for your help thus far I’m sure my stupidity is tough to deal with.

This is what I got.

I don’t need the last room as I want it to simply unload once the player goes into another level. But I cannot think of any way to hold onto the variables that the room actor holds and bring it to the next one.

I at least need the entrance/exit location so I can align the next room and then there are other random variables I want to bring along too but it’s impossible to get a ref of this actor just within this level.

  1. Do you mean in each separate level actor I just put a manual variable with it’s name? Seems easy enough would get convoluted possibly since I’m trying to get this as dynamic/streamlined as possible.

  2. No. The entrance of each level is centered on it’s 0,0,0 and all level geometry is child of that, so then I could theoretically just get the previous exit and align the entrance. Since it is random where everything is aligned this would ensure I don’t have to manually set this up.

  3. Yeah I already have lots of actors that will spawn in the level so streaming is a must for that fps savings.

  4. How would I set a level’s id?

  5. Yes. It is all procedurally generated from a seed based on the current time or what a user sets.

Alright dude I’m sorry but I’m just not understanding how I accomplish something like this at all.

I’ve been messing with this for over a week and about just 6 hrs today and I absolutely do not understand how I actually communicate between levels with bps.

At first I was trying interfaces to pass along a seed and the info for what level I would spawn and other stuff. But interfaces actually don’t let you do that? It’s just a function that doesn’t actually bring info over?

I’ve watched multiple tutorials and read all the official docs on them and they just aren’t making sense.

So then I wanted to try using game instance and it’s basically the same, I try to make each level have it’s own room actor that basically is a bp with the level geometry and then the exit/entrance doors and some volumes to know when the player enters or leaves(to make the call to spawn the next one) but I can’t figure out how you would dynamically communicate this info with each other.

After a certain point I’m going further and further away from my og idea of it being random gen as I’m now being forced to manually assign exits/entrances and room dimensions between levels to force them to stream correctly using the load level instance node. But this is the exact opposite of what I’m trying.

This is my current order of doing things but it feels incredibly convoluted. And I’m not smart enough to make this dynamic and more “Scalable” I guess? It doesn’t make sense to do it this way since I’m forced to do it manually for all data, I can’t pass stuff along.

  1. Persistent level with the bare essentials needed for the game.
  2. Begin Play → Load Level instance “Start Room” at 0,0,0
  3. “Start Room” Level Begin Play → Spawn “Room Actor” and set the Rooms’ “Type”.
  4. “Room Actor” Begin Play → Cast to “Game Instance”(Get Seed) → Switch On Enum for “Room Type” → Generate The Actual Level BP from that. And how it generates is random from seed and type.
  5. Generate Random Geometry(Disabled for now I’m manually just putting down a square and then entrance/exits.)
  6. Add each “Exit Point” to an array and add their locations to the parent who spawned the Actual Room Actor BP.
  7. From it’s parent, call an event to spawn the next room off a random exit point.
  8. Repeat.

Ok. Main thing is, you can DEFINITELY have your random gen :slight_smile:

I don’t know if you want to generate all at once, or as the player walks through, I think it’s the latter, right?

If your rooms are blueprints, and you are happy with that, I’d say, stick with blueprints, you don’t need to use streaming at all. You only need streaming if you have a LOT of stuff to load.

As far as passing info with an interface goes, you can pass all the same info ( and get answers ), that you can with a custom event, it’s just that a blueprint interface doesn’t assume what kind of actor it’s talking to.

You use custom events or BPIs just like you would if everything was in one level, because even if you’re streaming, you have to wait until the level is loaded before you can talk to anything in it. You can’t do anything before the level has loaded.

The garden maze I showed does things on the fly ( not pre-calculated ), as the player moves around, they are hitting collision boxes, which cause the blueprint they are currently standing in, to load a new random blueprint just around the corner etc.When the new blueprint is connected, there is some ‘dialogue’ between the two blueprints, because when the player leaves, you have to know which actors to destroy.

Am I saying anything useful?

If I’m still missing the point, there are two ways to go:

  1. You can focus on just the exact moment you’re having a problem with. Make it very simple, what exactly is communicating with what, where is your conceptual problem?

  2. We can hook up on discord if you like and discuss it, I have a server at Discord