I have this code for making an AI randomly every set amount of time. So every 5 seconds it makes a random prefab. Every 40 seconds it allows one more prefab to be made. I am doing this because I am making a Store sim and I want costumers be created and enter the store and the number of costumers allowed in the store slowly increase making the game harder over time.
The error Im getting only happens when I run the game in Unity3D and the moment the 5 seconds are up and its time to make a Prefab this error fills the Log and crashes unity.
if I run the game as a EXE it runs fine making the AI every 5 seconds like it should. But after some time (anywhere between 20 seconds and 3 minutes of running the game) it crashes giving me an error saying to many threads. I dont code in c# so im not sure how my code is making a thread to begin with and why it is giving me that error. Here is the code:
another thing is before I had it running in the Update() and that works never gives me a thread error or crashes the only problem with it is that I dont know how to make it create a AI every X amount of time and make it frame independent. The way it is written now if I have it in the Update it will make a AI ever seconds.
So my question is:
so anyways after a lot of testing i found out that using a timer is what makes that error. dont ask why i have no idea. but when i put it in the Update() it works only problum is the frame rate changed depending on the computer and the game itself. so i put it all in a
so it looks like:
and i just make the timer however many seconds it will be * 60 because i have it running 60 frames per seconds (at lest thats what it has come out to be)
answered Mar 22 '10 at 02:35 AM