I am working on something similar to a tile map that requires flexibility that tile maps do not seem to work for. Right now, I have an array of terrain data that terrain game objects are dynamically loaded from around the player and then discarded when they are out of the player (well, camera)'s range. As I increased the amount of tiles loaded around the player, I found that I began to get this error:
ERROR:GAMEOBJECT: Could not spawn an instance of prototype /main/objects/terrain.goc.
ERROR:GAMEOBJECT: Unable to create instance. Out of resources
around the time that 1024 objects were created. I guessed it was a project configuration issue, and changed max_count, max_resources, and max_instances up from 1024 to 2048 hoping this would solve the problem. With about 1500 tiles attempting to load, I still got the error. In an attempt to get an idea of what was causing the problem, I ran a simple test script:
local foo = {}
for i = 1, 1024 do
foo[i] = factory.create("#terrain_factory", vmath.vector3(0, 0, 0), nil, {})
end
The terrain object instantiated was a simple script + sprite + collider, and the behavior was unaffected by adding / removing the collider component. The terrain script has functionality to send the sprite a “play_animation” message but it is not called automatically.
With max_count, max_resources, and max_instances set to 1024, I got three of the error mentioned above upon execution. This made since due to three other objects present in the scene, an object running the debug script, a player object, and a camera object for transformation relative to the player. At first I thought the problem had to do with sprites and not game objects, but the fact that there were three errors and the fact that the world and camera objects lack sprites suggests the issue lies in the instantiation of game objects in general.
As I lowered max_count, max_resources, and max_instances to 512, I got a large number of errors, presumably 512 + 3. However, as I raised the variables to 2048, I did not stop getting errors; I continued to get two errors. After some experimentation, it seems that the culprit setting is max_instances, and that max_instances is effectively capped at 1025. Do you know what might be causing this? This bug is causing a lot of frustration and I imagine there might be other developers having problems due to this bug.
I am running the editor on OS X, with 4 GB RAM, in case this turns out to be some platform or memory-related issue.