I would like to make somthing similar to Binding Of Isaac as a school project.
I had the idea to make about 50 levels, and then in the main level, randomly select from one of those when the player walks into the next room, but keep in memory those, which are already loaded. Is there any way to do that?
I suppose I should use level streaming, but how to do the random part?
What you’re asking is a pretty general question. If your query is how to randomize levels, then what you’re after (I’m assuming) is some sort of procedural generation? Do you want to create actual levels (as in seperate .umaps) or just content within the current level?
If you want to do it like Binding of Isaac, i would begin with square rooms. The reworked game has bigger rooms in it too, but lets leave it to rooms of the same size.
I guess the general idea is to make all your rooms and put them into a list. Then you need a system that tracks every placed room in a 2D Array or something like that. You would need to know where a room is, and where not. Isaac also has a START Room for every floor. So this is the beginning. Than he just puts room next to room with some rules like “Boss Room has only one room next to him + devil/holy room”, or “Secret1 room needs to be between 3 rooms” and so on. As long as you have the array that contains the information about all levels placed, it should be easy. You have a list of rooms that need to placed, like itemroom, boss room and a list of rooms that can be taken randomly by just using one of the indeces. If you don’t want a room twice, you can just make a 2D array that also has a bool “Taken” and set it to true as soon as the room was used. You just need to check if the random room was taken already or not.
This is my idea about it. The exact implementation is up to you.
The best way would be to randomize content in the level, for ex 2 monsters, 3 rocks etc.but that would exceed my knowledge on how to do that.
The easiest way would be to make a bunch of .umaps and then just randomly select from one of those when the players hits a door trigger.
At this time, you aren’t going to be able to use random generation with level streaming without going into C++.
You could however use streaming and teleport your player to one of the 50 rooms randomly. You would just have the rooms spread all over your persistent level, but steamed out, and then when it chooses a room to teleport you to it would also call for the room to be streamed in.
As for how you actually do random, that really depends on how random. Doing it completely random is easy, such as random int 1-50 fed into a switch on int. If you want to put some intelligence behind what room might lead to another room it can get quite a bit more complicated(enough for quite a few separate answerhub questions for each problem you run into).