b3agz / Code-A-Game-Like-Minecraft-In-Unity

Project files for a Youtube tutorial series on coding a game like Minecraft in Unity.
304 stars 236 forks source link

Threading issue #11

Open FeaXR opened 4 years ago

FeaXR commented 4 years ago

I'm currently at part 12-Treading, and I've got a weird issue. I did everything as it's said, my code is exactly like in the provided assets folder, but if I don't lock the modifications Queue in this line: modifications.Enqueue(Structure.MakeTree(pos, biome.minTreeHeight, biome.maxTreeHeight)); then I get a NullReferenceException when I Dequeue (line 141 in the provided script), and there are nearly no trees in the map, except for a few that are farer away from the player. The Queue that I get is null. If I lock the Queue, this problem doesn't appear, but then I can't destroy the blocks of the trees.

FeaXR commented 4 years ago

I also tried to swap all my code to the provided ones, but the same error occurs. It worked fine before this part, so it originates definitely somewhere here.

FeaXR commented 4 years ago

Another strange thing: it seems like, that if I lock it, only those trees can't be destroyed, that are on chunk edges.

VolodyTrekalo-coder commented 4 years ago

По моему проблема в подгрузке. Попробуйте Return( указать сектор );

FeaXR commented 4 years ago

Do you mean the return of my MakeTree function? It always returns a non null value