Hello, i am making an runner game and as it stands right now i am generating the floor and obstacles with a ForLoop to create a everything, the obstacles are placed at random and when a player hits them the level restarts. I am using a Save Object to save the locations of the obstacles into a transform array and using that to respawn them on level restart.
Works as it should, the only issue is that when i tried to increase the size of the level from 15 floor tiles to 200(the actual size) when its time to load i take a massive performance hit. I guess its to be expected since i am placing a ton of actors at the same time.
So i thought about adding a trigger volume at the end of each tile and have a new one spawn when the player overlaps and the same thing for the obstacles, my issue is that if i generate the level like that on real time as the player passes through the volumes and save those locations in an array, how can i go about respawning them exactly in those locations during runtime when the level restarts?
I hope this makes sense to someone, thanks!
When a tile spawns, you can give it an ID, just an integer. As you spawn the obstacles on that tile, you associated them with that ID in the save game.
Next round, when a new tile spawns, it gets its ID, and can look in the save game to see if there are save obstacles. If there is, it remakes them, if not, it spawns a random config, and saves that.
Thank you for the reply, would it be possible to give me a little more details as to how i can go about doing that in blueprints? How do i associate them with that ID in the save game?
That’s the part that’s been confusing me the most.
Every time you spawn a tile, you add one to a tile ID counter. For the tile we are about to spawn let’s say it is 25.
For the sake of simplicity, we just spawn a cube obstructor, in one of 4 positions. We can either remember the positions with a number ( 1234 ) or the actual vector. Doesn’t matter.
So now, we write into the save game ( 25, 3 ) - 25th tile, cube is in position 3.
Later, the player restarts the level. We are busy spawning tiles, we get to tile 25, and see the cube has to go in position 3
More generally, you would probably have an array of structs. Each struct has all the random spawning info, and the index into the array of struct is the tile ID.
If you need more info, maybe tell me a bit more about what sort of obstacles you’re spawning.
Thank you for taking the time to help out with this, i know it must be kind of basic.
Your latest reply sure helps, i understand what i need to do now in theory, however i am having a little trouble with the actual application of it. More specifically, i am assuming that the tile ID and the positions (1234) are integers that i am saving.
During the load how would i know that i’ve reached the tile 25 from the example and then check if it contains a saved location and if it does , spawn the cube?
The obstacles are cubes by the way.
If you could please tell me what kind of nodes i would need it would definitely be a massive help.
Thanks again!