diff --git a/Assets/GameCode/ZombieSimulatorBootstrap.cs b/Assets/GameCode/ZombieSimulatorBootstrap.cs index ebec8bc..9d3f4a5 100644 --- a/Assets/GameCode/ZombieSimulatorBootstrap.cs +++ b/Assets/GameCode/ZombieSimulatorBootstrap.cs @@ -48,7 +48,7 @@ private static void NewGame() private static void CreateZombies(EntityManager entityManager) { - NativeArray zombies = new NativeArray(Settings.HumanCount, Allocator.Persistent); + NativeArray zombies = new NativeArray(Settings.HumanCount, Allocator.Temp); entityManager.CreateEntity(ZombieArchetype, zombies); for (int i = 0; i < Settings.HumanCount; i++) @@ -58,6 +58,8 @@ private static void CreateZombies(EntityManager entityManager) // We can tweak a few components to make more sense like this. InitializeZombie(entityManager, zombies[i], randomSpawnLocation); } + + zombies.Dispose(); } @@ -74,7 +76,7 @@ public static void InitializeZombie(EntityManager entityManager, Entity zombie, private static void CreateHumans(EntityManager entityManager) { int length = Settings.HumanCount;// + Settings.ZombieCount; - NativeArray humans = new NativeArray(length, Allocator.Persistent); + NativeArray humans = new NativeArray(length, Allocator.Temp); entityManager.CreateEntity(HumanArchetype, humans); for (int i = 0; i < length; i++) @@ -96,6 +98,7 @@ private static void CreateHumans(EntityManager entityManager) entityManager.AddSharedComponentData(human, HumanLook); } + humans.Dispose(); } private static float2 ComputeSpawnLocation()