You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello ! Thanks for this tutorial ! It's really great !!
I think there is a problem in this part of the code.
As you said in one of your video, when you remove an element from the list, the indexes are recalculated.
In your checkViewDistance method, you use an index to find the chunk that needs to be kept. that's ok, but why does the for loop goes on (with the indexes recalculated) once the chunk is found ?
In my opinion, it you be better if there was this code : (with a break once the chunk found)
for (int i=0; i< previouslyActiveChunks.Count; i++) {
if (previouslyActiveChunks[i].Equals(chunks[x, z].coord)) {
previouslyActiveChunks.RemoveAt(i);
break;
}
}
Or even better, as the method Equals exists for the ChunkCoord class : previouslyActiveChunks.Remove(chunks[x, z].coord);
Thanks again for your videos !! A real pleasure to watch !!
Cheers from France !
The text was updated successfully, but these errors were encountered:
For some reason I don't figure yet, some ChunksCoords are present multiple times in previouslyActiveChunks.
I think this is due to activeChunks Add() calls in various places in the code, with new Instances of ChunkCoord...
However, maybe the better way for this issue is to browse the list from end to beginning :
for (int i = previouslyActiveChunks.Count - 1; i >= 0; i--) {
if (previouslyActiveChunks[i].Equals(new ChunkCoord(x, z))) {
previouslyActiveChunks.RemoveAt(i);
}
}
Code-A-Game-Like-Minecraft-In-Unity/24-loading-and-saving/Assets/Scripts/World.cs
Line 283 in df5ace5
Hello ! Thanks for this tutorial ! It's really great !!
I think there is a problem in this part of the code.
As you said in one of your video, when you remove an element from the list, the indexes are recalculated.
In your checkViewDistance method, you use an index to find the chunk that needs to be kept. that's ok, but why does the for loop goes on (with the indexes recalculated) once the chunk is found ?
In my opinion, it you be better if there was this code : (with a break once the chunk found)
Or even better, as the method Equals exists for the ChunkCoord class :
previouslyActiveChunks.Remove(chunks[x, z].coord);
Thanks again for your videos !! A real pleasure to watch !!
Cheers from France !
The text was updated successfully, but these errors were encountered: