Пример #1
0
    private void DestroyDistantChunks(Int3 center)
    {
        for (int i = chunks.Count - 1; i >= 0; i--) // loop backwards to avoid skip-update glitch
        {
            Int3 dis = Int3.Dis(chunks[i].gridPos, center);

            bool thisChunkIsTooFar = (dis.x > renderDistance) || (dis.z > renderDistance) || (dis.y > renderDistanceVertical);

            if (thisChunkIsTooFar)
            {
                Destroy(chunks[i].gameObject);
                chunks.RemoveAt(i);
            }
        }
    }