Nested for loop to spawn HISM causes crash

Hello, I am trying to make infinite level stream generation for my game, think chunks or something like Minecraft.

Except there is absolutely 0 voxels, cubes, level editing, etc… I just want to stream levels infinitely like Binding of Issac’s rooms or Spelunky, etc, something.

The unfortunate part is I am not smart enough to know how to infinitely stream levels. My “solution” is to spawn an actor at runtime that will then spawn simple HISMs in “nested forloops”(XxY) that will then stream a level on it’s location when a very large collision sphere attached to the player intersects it. When the sphere is no longer colliding it unloads the streamed level.

This works somewhat well, it does lag and hitch which I don’t understand.(Is level streaming not asynchronous??) But that’s a different thread anyways IMO.

So the problem is that world size is inherently limited by the amount of “Stream Markers” I can spawn in. A nested for loop set to X(1000) x Y(1000) should produce 1 million total markers. That is a pretty significant amount no doubt. But if a player is saving and loading and playing over “x” amount of time they will eventually reach the edge. Can’t have that.

But any number above 1M(1000x1000) seems to cause a crash. It normally takes around 10 seconds to finish placing them, I have absolutely no qualms about sticking a loading screen in and waiting a full 60 seconds for much more of a larger world.

So what gives? Why is more instances causing a crash? It’s not like the math suddenly doesn’t work as we enter larger numbers? Is it simply just UE can’t handle numbers this large? Even HISMs?

I thought maybe it’s trying to spawn too many at a time since its just “forloop x forloop” but adding a delay anywhere in the “Add Instance Loop Sequence” breaks it in it’s entirety.

I’m not sure where to go from here except converting to C which is gonna be a due time thing but I still need to figure out how to make this be better I guess before then as I’m even worse with C.

Any help, advice or tips would be appreciated. Thank you.

It is for blueprints, loops are slow…

Divide the work into smaller batches, do not attempt to do it all in a single frame. Minecraft chunks are 65,536 only. And, afair, even a single chunk is not generated in a single frame.

But any number above 1M(1000x1000) seems to cause a crash. It normally takes around 10 seconds to finish placing them, I have absolutely no qualms about sticking a loading screen in and waiting a full 60 seconds for much more of a larger world.

I run a quick test and an ancient 4c / 4t CPU I use for testing is happy to make several million instances - I build a batch per frame using the actual Tick :slight_smile:

It takes under 10s to make 2 millions but the algorithm is super simplistic so mileage will vary, of course.

2 Likes

How do you do it “by frame”? Isn’t tick frame dependent already?

I’m thinking beginplay with a looping timer?

Is there an upper limit of how many HISMs UE can actually handle? It doesn’t need to be infinite just big enough a player won’t reasonably reach the edge unless they stick a weight on their W key for a while…

I intend to convert the most resource intensive stuff into c but I still want to get a “working” blueprint prototype.

It does not matter. Each tick you spawn some (thousands) of HISMs, this will go as fast as it can while still maintaining a degree of responsiveness. You can set the tick to any value anyway. This was just a test to see if we can go above 1m, we absolutely can provide we spread the spawning over time and not force the engine to create too many in a single tick.

You could use a timer but then we will not go as fast as we can - it will be more controlled, though.

Is there an upper limit of how many HISMs UE can actually handle?

Probably. But the idea is to spawn chunks around the player and then get rid of them when they move away.


I am assuming you’re familiar with:

1 Like