#Hey this might be a bit of a complicated

1 messages · Page 1 of 1 (latest)

west acorn
#

I made this a thread so it doesn't get lost

cedar lantern
#

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

west acorn
#

yeah try with minimum values when debugging

cedar lantern
#

i know they work though

#

i know that 10 x 10 works

#

nothing will fit in that though

west acorn
#

yeah I was just asking for a screenshot so we can better understand your problem

cedar lantern
#

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

west acorn
#

but yeah seems like you are running out of RAM during the generation though

cedar lantern
#

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

west acorn
#

just googled this

cedar lantern
#

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

west acorn
#

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

cedar lantern
#

yea nah i get that

#

even a build is freezing on boot

west acorn
#

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

cedar lantern
#

I'm not completely familiar with coroutines would it change much?

#

also do you mean like with a waitforseconds?

west acorn
#

yeah that.

#

could make it easier to debug too

cedar lantern
#

true

#

like i also said

west acorn
cedar lantern
#

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

west acorn
#

Dividing your map into chunks is good

cedar lantern
#

Famous last words

#

knowing what the code looks like now

#

its gonna be like

#

hard XD

west acorn
#

You could make it a coroutine and wait a frame after every chunk generated, or so

cedar lantern
#

yea

#

would also let me use a loading bar too

#

ill do that

west acorn
#

and you can always try to convert it back to a function (non-coroutine) once you optimize it

cedar lantern
#

yea

west acorn
#

not a big process. I really suggest learning coroutines they arent that hard and very useful

cedar lantern
#

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

west acorn
#

tru

cedar lantern
#

im going to try WaitForEndOfFrame

#

so every frame will make one tile

#

odd

#

even thats freezing

#

did i do the code right?

west acorn
#

make sure to call it with StartCoroutine(GenerateMapCoroutine())

cedar lantern
#

im starting the coroutine in the generatemap already

#

i know that much about coroutines

west acorn
#

idk what this means if(map[x,y] == 1)

cedar lantern
#

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

west acorn
cedar lantern
#

sorry XD

#

adhd go brrrrr

west acorn
#

anyway, your Coroutine syntax looks ok

cedar lantern
#

ill try waitforsecconds now ig

west acorn
#

are you sure it doesn't freeze before you even get to that loop?

cedar lantern
#

i mean it could be

west acorn
#

you need to work backwards a bit

cedar lantern
#

thats what i was doing when waiting for responces

#

so ill keep at it

west acorn
#

try returning after RandomFillMap and then CaveRefine to see if one of those is the culprit

cedar lantern
#

so just return after?

#

like

#

RandomFillMap();
return;

#

etc?

west acorn
#

well in a normal method you would return; but in a coroutine you yield break;

cedar lantern
#

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

west acorn
#

oh by the way

#

i see you use Debug.Log when spawning a tile

cedar lantern
#

yea just to know how many there are

west acorn
#

it's super expensive

#

if you get like 10,000 Debug.logs in one frame..

cedar lantern
#

i tryed to remove that

#

but it was still not happy

#

let me try again

west acorn
#

ok just pointing out, its super heavy

cedar lantern
#

it may work better in the IEnumerator

west acorn
cedar lantern
#

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

west acorn
#

sure and you can always make CaveRefine into a coroutine too

cedar lantern
#

good point

#

so more than one coroutine is okay?

west acorn
#

I think you call coroutines from coroutines this way yield return AnotherCoroutine();

cedar lantern
#

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

west acorn
#

hey at least you got something to work with now

cedar lantern
#

sorta

#

waaait

#

ok so

west acorn
#

please type complete sentences not single words

cedar lantern
#

sorry just how i think

#

:p

west acorn
#

d:

cedar lantern
#

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

cedar lantern
#

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

cedar lantern
#

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