Hey! I am trying to make an infinite room generation from premade rooms.
The room includes a room with a collision box inside and spawnpoints. The character has that red sphere which overlaps with spawnpoints to generate rooms.
For now it works for one direction but when I add more off them, it crashes and says that it detected infinite loop. I assume that it means that the spawnpoint is not being deleted before telling to spawn a room and it generates the rooms in one place infinitely.
I tried so many things to fix it, if statements, different ways to check overlapping, timers, but I just can’t find the solution…
Oh and I’m a beginner, I started using Unreal a couple days ago so beginner friendly help would be appreciated
I did exactly this with maze segments. When you spawn the room, you can set a reference to the spawned room. If that reference is set, don’t spawn another.
But how? I thought that if a spawnpoint of the other room detects that there is already a room it won’t spawn it and delete itself. How else can I do that?
Like this. Each spawn point consists of the location, and a reference to what’s connected there.
If there’s an overlap, check the reference. If it’s null, connect something and set the reference at the same time. Also, set the reference in the spawned blueprint to this room.
You can set the reference variable to be exposed on spawn, so you can set it as the room is being spawned
I don’t know exactly what your system / logic is, but with mine, if room A spawned B, then I went back into A, it would unspawn B. So, if I walked in that direction again, maybe C would spawn etc.
Maybe you only spawn once. In which case, it makes sense to remove the spawn points.
If A spawns B, then the spawn points on A and B should be removed ( B as it’s spawning ). ( Only remove the connected spawn points, of course ).
For now my system is supposed to be that my spawnpoints, which are a part of rooms blueprint, spawn the same room with the same amount of spawnpoints so it can go infinitely as I explore. I made a collision box inside the room to check if a new spawned spawnpoints overlap with a room which would mean that there is a room in that place so I call a delete function without spawning a room.
Is there a way to store locations of already spawned rooms in Spawn Room Function? So if they match that function will do nothing and delete the spawnpoint?
Don’t try and write one big fat spawn room function. You will go nuts. Also, location is a bit unreliable. Is that good enough for you? What if it’s one unit off?
I’m assuming you have set it up so that each room manages the spawning of the rooms attached to it, and they manage what’s attached to them, etc.
The easiest way is to just keep references with the rooms
Hi, I don’t know if you’re gonna reply but I reworked my system with a different approach and it works! But there is one problem…Is there a way to generate a chunk of rooms at the start depending on the size of my character’s sphere that overlaps with spawnpoints?
No, I want to spawn more than one room on the start of the game, because the collision sphere doesn’t seem to work when the spawnpoints are spawned in it
It’s almost exactly what you have now, except you will have a way of stopping the rooms spawning all the way to the horizon!
Say you put a square room with 4 doors in the level. When you start it will spawn 4 rooms, and they spawn other rooms, and they spawn…
If you use a token, it stops this sort of stuff.
The start room has a token of 2, say, and gives each of the spawned rooms a token of 1. Which means they pass a token of 0, and the spawning stops.
Does it make sense? The player is still triggering it, but not with a massive collision sphere, but rather just walking into a room. When they walk into a room, that room gets a token to spawn.