how can i refrence a level or give it a tag?
i am spawning levels randomly and i need to distinguish between them becaus they have diffrent sizes, i tried with this, but the index dosnt line up with the level that is spawned…
What are you doing on the right? ‘load level instance’ or… ?
yes,
load level instance
Ok. Unless you specify the transform ( location / rotation ) for the load, the level will load where it is in it’s default map file.
If you want to connect randomly spawned levels together, you’ll need to specify those params
Exactly how you do that really depends on what’s going on in your game. Maybe if you can give a bit more info?
yes, the problem is:
i have five big rooms, and five small ones
when i come colse to the door, a random one out of these ten rooms is loaded.
but if i spawn the big ones on the same position as the small ones, ther is overlapping with walls ect.
so i need the blueprint to know if it is a big one (0-4) or small one(5-8) and then modify the position vectore based on that
but i dont know how i can get the room number as a tag/intager/…
What I did, was put marker actors in the levels at the connector points. I wrote a bit of BP, to save those actor transforms to the save game.
Now my levels always line up, because a vector calculation can be used to figure out how to connect those marker points together.
That’s the most general case. If your case is simpler, you might be able to get away with a simpler concept. It might be enough to say ‘room size + rotation’.
If you’re interested, I can put the code up here…
yes please! would help alot
what kind of data table did u use?
So I made a simple actor which has location and rotation
It has some text on it so I can see what I’m doing. It has a bit of code, to write it’s transform, relative to this map, to the save game
Notice, it’s ‘call in editor’, so I can write this to the save game with a button
In my other level, I have the loader BP, same concept, but it reads the transform from the SG
When I ask it to load ( in game or in editor ), it gets it exactly right ( the doorway is on top of the loader point )
The calculation is quite simple, but it did take quite a while to figure out
Now I’m pasting it in, it looks like a bit of a mare. But it’s actually quite simple ( this code is in the loader )
All it’s doing is figuring out where the new level needs to be, to line up the markers.
PS: Using the save game is far better than a datatable, because you can just write your marker transforms to it from the editor, you don’t have to fiddle about it with typing numbers in ( exactly what I wanted to avoid ).
i am super confused by this, could you share the project?
i dont have a read save game function…
It’s just a function library function
The project is huge, so can’t share it. I can make a fresh one with just the crucial bits in, but that will quite a lot of work. Do you think it’s what you’re looking for?
You don’t have to use the save game stuff, you can just type numbers if you want…
If you only have a couple of level sizes, and they’re square ( for instance ), you can just add an offset when you load it.
Another thing you can do is just shift everything in your level so that the load point is at 0,0,0. Then you can just load it and it will already be shifted.
But if you’re looking for a general solution, you will have to do something like this vector maths…
i tried to sketch out what i am trying to do
i have level one, with three doors A, B, C.
and a second level, also with doors A,B,C.
user steps into the collider on door A: level2 is loaded and its door C is connected to the door A of level 1
how can i communicate between the two levels?
i want to use levels of different size, so i cnat just use a plaine offset
Yes, this is exactly what I’m talking about
I’m assuming that in level1, the origin is here
So if you just load the level as an instance, it’s right on top of what you already have. You need to load it with an offset.
If your levels are always quite square shaped and have doors at well known points, you can probably work out how to do this during the load. But if you want a general solution, you need some way of automating this, which is what I did.
In your diagram here, when I walk out of door A level2, you need to load level 1 here
Imagine if you want to connect these
Now you have shift and rotate to load. See what I mean?
So what I’m saying is, as long as you know the transform of the door in the level you want to load, you can load that level in the right place, as long as you get the math right. And the math is quite easy.
The door transform is just its position and rotation
what is “mysavegame” (where does the cast lead?)
That’s just what I called my save game
To be clear, you don’t have to use the save game, it’s just my way of doing it without any typing.
You can have a huge array somewhere with all the data in.
Looking back at this post, if you only have small and big rooms, and that’s all you need to distinguish between, you could just put something in the level name, to tell them apart.
Then, depending on the level name, you know how far to offset it when you load.
Another way would be an array of level references, and an array of level sizes. When you choose index 7 ( say ) randomly from the level array, you just grab index 7 from the size array and you know how far to offset.
( I’ll leave you alone now … )
ok thanks for all the help :)#