#Hey this might be a bit of a complicated
1 messages · Page 1 of 1 (latest)
thank you
ok so even trying 200 by 200 tiles its freezing
let me restart and try 100 by 100
god i need to try even lower
yeah try with minimum values when debugging
i know they work though
i know that 10 x 10 works
nothing will fit in that though
yeah I was just asking for a screenshot so we can better understand your problem
I mean I can give you a screenshot but it's just going to be a big cube of dirt
The issue is that I can't generate large Maps it freezes my Unity
but yeah seems like you are running out of RAM during the generation though
i have 48 gigs how
is unity capped?
ok so
If it's performance-based options do I have?
Because I don't really understand a lot of the code as much as I probably should at least when it starts getting into the custom structures class and lists
i was thinking make chunks
but i am not sure how to do that as of now
just googled this
i see
one sec
imma try a build
im using a rule tile
so that would take up a lot more ram than just a normal sprite
I don't have enough experience with memory management (and the issue might be something else too) to guide you further, hope someone else can help
one thing i can suggest is making your generation method a Coroutine
so it doesn't try to generate everything in the same frame
but spread over a few frames
I'm not completely familiar with coroutines would it change much?
also do you mean like with a waitforseconds?
well with my logic it would spread the memory consumption/allocation over a few frames, minimizing your chance of running out of memory
yea
I'm curious if it's just too much math for the unity engine to deal with all at once for something as large as I want so I'm wondering about chunks
But like I said I would still need to figure out how to accomplish that and I'm not fully sure where to start hopefully it wouldn't be that difficult though
Dividing your map into chunks is good
Famous last words
knowing what the code looks like now
its gonna be like
hard XD
You could make it a coroutine and wait a frame after every chunk generated, or so
and you can always try to convert it back to a function (non-coroutine) once you optimize it
yea
not a big process. I really suggest learning coroutines they arent that hard and very useful
i know
Here let me just copy a message I sent in general an hour or two ago
"I always used to think that I had somewhat of a decent grasp on unity and c# but as I try and do certain things I'm realizing that I basically know nothing other than basic if statement code using the default provided voids"
Coding is not hard from my experience
BUT
Coding something that efficient does the extremely well and doesn't have errors
THAT is hard
tru
im going to try WaitForEndOfFrame
so every frame will make one tile
odd
even thats freezing
did i do the code right?
make sure to call it with StartCoroutine(GenerateMapCoroutine())
im starting the coroutine in the generatemap already
i know that much about coroutines
idk what this means if(map[x,y] == 1)
oh ok so
its for the grid of tiles
thats a Multi dimensional array
it keeps track of the state of each tile
so if its map[13, 26] = 1
that means at that spot on the grid there is a tile
yes this is all i needed to know :D
anyway, your Coroutine syntax looks ok
ill try waitforsecconds now ig
are you sure it doesn't freeze before you even get to that loop?
i mean it could be
you need to work backwards a bit
try returning after RandomFillMap and then CaveRefine to see if one of those is the culprit
well in a normal method you would return; but in a coroutine you yield break;
okay
first im going to just remove cave refine
or slash it out
as thats not needed to make tiles
well it runs now with bigger tiles
but its odd
that should be 1000 by 1000
let me move the wait for frame
yea just to know how many there are
ok just pointing out, its super heavy
it may work better in the IEnumerator
replace it with a counter and print the counter's value afterwards. Otherwise 500x500 map will result in 250 thousand logs
okay
seems like its CaveRefine(); that is killing it
that makes sense
but like
thats like 70% of the code is that side of the cave gen
I think processing it as individual chunks is my only hope
They won't be physical chunks that I can mess with in the hierarchy because it's just going to be tiles but I can still try to separate each generated chunk
just gotta try to think how
I'm going to determine if it's the spawning of the tiles that is causing issues or if it's the math by removing line 70 "tilemap.SetTile(new Vector3Int(x, y, 0), worldTiles[0]);"
If it's the Sprites being spawned that is the issue then that makes the chunk problem theoretically easier
if its the math
god help me
ah... just ,y luck XD
its the math
i have an idea
going to make it wait before it runs the cave refine
sure and you can always make CaveRefine into a coroutine too
I think you call coroutines from coroutines this way yield return AnotherCoroutine();
yea
going to start with this
okaayy
now nothing shows up
i can tell that its running the new cave refine
the debug.log is there for GetRegions
Wait a minute if it's all happening from the start method there is no frame for it to wait for right?
let me try wait for seconds
dang still nothing
wait
i may have goten it
hmm well it can do 200 by 200 now
hey at least you got something to work with now
please type complete sentences not single words
d:
its no longer even trying to do CaveRefine()
i made GenerateMap() back into a function and that made it gen blocks again
but now the GenerateMap()is no longer doing anything
so i dont think it likes the yields
That function should remove the small floating islands and tiny little caves
along with drilling tunnels
so if i comment out MapRefine i can get this 2500 x 800
and it loads in like 15 seconds
so we know its that for sure
but that branches out into everything else
so that still leaves a lot open to look at
i found out whats doing it still dont fully know how to fix it tho
That is the most recent version of The Script it is something to do with connect rooms and its corresponding functions/methods (I think methods is the right word?) when I comment out it's able to generate fine it just takes a little bit
im not sure how i would make ConnectRooms into a IEnumerator though
anyways i need to sleep and try more tomorow